Redirecting a web page help
I have a web page that when people enter it's URL into their browser I want the page to redirect to the same URL but with an https.
I'm using PHP and I tried making index.php just call https://www.index.html but it didn't work and I don't know why.
This is the php code I used:
echo "
";
exit;
Is there another way to do this?
Thanks...
pr0gr4mm3r posted this at 19:17 — 1st July 2007.
He has: 1,502 posts
Joined: Sep 2006
"https://www.index.html" is most likely your problem. That's not a valid link.
This may be a better way:
<?php
if($HTTP_SERVER_VARS[\"HTTPS\"] != \"on\")
{
$newurl = \"https://\" . $_SERVER[\"SERVER_NAME\"] . $_SERVER[\"REQUEST_URI\"];
header(\"location: $newurl\");
}
?>
benj posted this at 19:39 — 1st July 2007.
They have: 36 posts
Joined: Apr 2007
That works fine for me all the time. I think that's the best way. Just correct your link and it should be cool. If it doesn't work try making it redirect to a popular website you know of and see if it works.
Just FYI, here's an html file I created that will redirect to this site:
benjisa.com
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.