FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

[Tutorial] Redirecting pages in HTML

 


mlima
There is a more simple way to do this for those who have cPanel, but for those who dont the better way do redirect a page to another is this.

To redirect page_X to page_Y we have to put this code in page_X:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>page_X</title>
<META HTTP-EQUIV="Refresh" content="5; URL=page_Y.html">
</head>
<body>
<div align="center"> Redirecting in 5 seconds</div>
</body>
</html>


Its very simple... The page_X will auto refresh for the URL that we want, in this case page_Y.

And thats just it. It may be useful. If you have any questions please post theme in this topic Smile
SamiTheBerber
If don't have cpanel, then you should do what cpanel would do, edit the .htaccess file.

Old style html redirect is also handy in some cases Smile
Star Wars Fanatic
If you just add this line into a .htaccess file in your public_html folder, it will do the same thing that CPanel does:

Code:
Redirect /olddirectory/oldfile.html http://yoursite.com/newdirectory/newfile.html
rvec
or in php:
Code:

<?php
header('Location:http://www.example.com');
?>


You should use the php if you want to write some script on that page before redirecting the user. Make sure that you send no output before the header and that no code after it will be executed (in most cases).

The html can be used if you want to redirect the user after a couple of seconds. For example after a user has send you a mail with your online contact form you could send all the info to a php file which will send the actual mail. This second page could show the user a message for 3 seconds that the mail has been successfully send and then forward him to the homepage.

The htaccess should be used in a case where you want all users visiting one page to be forwarded to another page. For example if you moved a page you could add this line to the htaccess to make sure all visitors including those following a link from another site will be redirected to the right page.
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.