I have a link to an https login page on the left nav of my site. The link is specified as an absolute url (i.e. https://mywebsite.com/login.php). That works fine and switches my user into https mode. My problem is that I have a separate site that I use for testing code before moving it to production (mywebsite-test.com). If I upload my production code to the test site, the link to the secure login page points to the production site (because of the absolute url in the nav bar). This is a problem since the login url is in the nav bar and is thus on every page of the site; it's not practical to have two different sets of code -- one with the test site name and the other with the production site name. Surely there's a better way to handle this? --Jeff
make the URL's dynamic:
if ($_SERVER['HTTP_HOST'] == 'mywebsite.com') { $url = 'https://mywebsite.com/login.php'; } if ($_SERVER['HTTP_HOST'] == 'mywebsite-test.com') { $url = 'http://mywebsite.com/login.php'; }
Thanks! I knew I was overlooking something obvious. And I guess it would be even better like this:
<a href=<?php echo "https://".$_SERVER['HTTP_HOST']."/login.php";?> >