Redirecting a web page help

They have: 12 posts

Joined: Jun 2007

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's picture

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's picture

They have: 36 posts

Joined: Apr 2007

frank727;221057 wrote: 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...

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:

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.