Redirecting page

They have: 5,633 posts

Joined: Jan 1970

Whats the code for that when user goes to my webpage the page redirects user automatically to another?

He has: 1,380 posts

Joined: Feb 2002

Place the following code in the section of your website:

<meta http-equiv="refresh" content="0; URL=http://www.mywebsite.com">
'

There will be a slight delay using that, so you can use PHP instead:

-create whatever the page name is, just with .php as the extension instead of .html (if your server can run PHP)
-inside the page.php file, insert the following code

<?php
Header
(\"Location: http://www.mywebsite.com\");
?>

The php version should have almost instantaneous redirection

Busy's picture

He has: 6,151 posts

Joined: May 2001

just a note on the php version, it must be put before any content is printed on the page or you'll get an error.

<?php
Header
("Location: <a href="http://www.mywebsite.com"" title="http://www.mywebsite.com"">http://www.mywebsite.com"</a>);
?>

...
is right

<?php
if ($black == $white) { $messed_up = "umm ok";}
Header("Location: <a href="http://www.mywebsite.com"" title="http://www.mywebsite.com"">http://www.mywebsite.com"</a>);
?>

is right as the if statement doesn't print anything to the page

<?php
Header
("Location: <a href="http://www.mywebsite.com"" title="http://www.mywebsite.com"">http://www.mywebsite.com"</a>);
?>

...

is wrong as has been printed to the screen.

He has: 1,380 posts

Joined: Feb 2002

But if you are redirecting from an old location to a new one...then you can just use the relocate file to do the redirecting from a blank page (just the PHP code) and then notify them of the move on the new page.

Busy's picture

He has: 6,151 posts

Joined: May 2001

true, but if you want to check if the person is logged in or not, if logged in, view the page, if not redirect to log in page ...

lack of info = confusion

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.