Misc


Sep
6

0


How to redirect pages with PHP, HML, htaccess, and JavaScript

Redirect Via php

{code type=php}<?
header( ‘Location: http://www.FremontTech.com’ ) ;
?>
<html>
<head> </head>

<body> </body>
</html>{/code}

ImportantThis must be the very first thing on the page!!

Redirect Via html

{code type=html}<html>
<head>

<meta http-equiv=”refresh” content=”5; url=http://www.FremontTech.com/”>

</head>
<body></body>
</html>{/code}

TranslationThe script says in 5 seconds refresh (redirect in our case) with this address. If you want instant redirect change 5 to 0

Redirect Via htaccess

{code type=html}#FremontTech.com Redirect Specific Pages
Redirect /Old.htm /New.htm{/code}
{code type=html}#FremontTech.com Redirect Specific Pages
Redirect /Old.htm http://www.yoursite.com/New.htm{/code}

TranslationIf Old.htm is requested give them New.htm

Redirect Via JavaScript

{code type=html}<html>
<head>

<script type=”text/javascript”>
<!–
window.location = “http://www.FremontTech.com/”
//–>

</script>
</head>
<body></body>
</html>{/code}


Redirect Via JavaScript with delay

{code type=html}<html>
<head>

<script type=”text/javascript”>
<!– function delayer(){
window.location = “http://www.FremontTech.com”
}
//–>
</script>
</head>
<body onLoad=”setTimeout(‘delayer()’, 5000)”>
<h2>Prepare to be redirected!</h2>

<p>This page is a time delay redirect, please update your bookmarks to our new location!</p>

</body>
</html>
{/code}

Important

The most important part of getting the delay to work is being sure to use the JavaScript function setTimeout. We want the delayer() function to be used after 5 seconds or 5000 milliseconds (5 seconds), so we pass the setTimeout() two arguments.

  • ‘delayer()’ – The function we want setTimeout() to execute after the specified delay.
  • 5000 – the number of millisecods we want setTimeout() to wait before executing our function. 1000 miliseconds = 1 second.

Page 2 of 212