-1

I am running a Wordpress theme with the following link hard coded to the template. How do I change it depending on the current domain the browser is at. Please note that I am using sub-domains.

From(https://www.foo.com/):

<a class="btn" href="https://armoires.foo.com/_Login/Login.php">

to(https://www.foo.ch/):

<a class="btn" href="https://ch.foo.com/_Login/Login.php">
  • Just make the link href="/_Login/Login.php"> – berentrom Feb 18 '14 at 09:11
  • Can you edit the particular page ? – Vinod VT Feb 18 '14 at 09:12
  • I do have full access to edit the page. My problem is that I have got only one Wildcard certificate, therefore I have created sub-domains to separate my French and Swiss language sites. I need some sort of PHP code that allows me to change the URL of the HREF accordingly. – damien_calvignac Feb 18 '14 at 10:14

3 Answers3

1

You can just remove the domain:

<a class="btn" href="/_Login/Login.php">

Sgoldy
  • 786
  • 3
  • 14
0

Change:

<a class="btn" href="https://armoires.foo.com/_Login/Login.php">

To:

<a class="btn" href="<?php echo home_url( '/_Login/Login.php' ); ?>">

This will only work inside a PHP file. Alternatively you'll need to use a relative link.

<a class="btn" href="/_Login/Login.php">
Nathan Dawson
  • 18,138
  • 3
  • 52
  • 58
0

So basically I did a switch case for this to work:

<?php
$path = $_SERVER['HTTP_HOST'];
switch ($path)
{
case 'www.foo.com':
  $link = 'https://com.foo.com/Login.php';
  break;
case 'www.foo.ch':
  $link = 'https://ch.foo.com/Login.php';
  break;
default:
  $link = 'https://com.foo.com/Login.php';
}
?>

Then

<a class="btn" href="<?php echo $link; ?>">