Ezilon.com - Target Your Audience, be Seen in Your Region

Redirecting a web page help

You are viewing this site as a guest. Join our community to get your questions answered and share knowledge. Active members may advertise and ask for a website critique.

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
ModeratorSponsor

He has: 544 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\");   
}
?>

Hey! It compiles! Ship it!

They have: 32 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: