Redirect

Web-master / Your website / Web Help

Redirect

.htaccess

Redirect 301/old/old.htm http://www.you.com/new.htm
/old/old.htm - the path and name of the old page.

Became a classic task of merging the names of the site with www and without it, is solved this way:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite\.com
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [R=permanent,L] . 
Or an alternative syntax:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
The designation [R=301,L] means: redirect the client and send him the status code 301 (R=301) and make this rule last (L).

Meta

<meta http-equiv='refresh' content='0'; url=http://newdomain.com'>
Page refresh function.
Content specifies the number of seconds after which the update will take place.

PHP

<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.newdomain.ru/newdir/newpage.htm");
exit();
?>

JavaScript

For example, automatically make a Click on the "Submit" button of the "searchform" form in 0.1 sec after loading the code:
<input type=submit setTimeout('document.forms["searchform"].Submit.click()', 100);>
location="http://www.newdomain.com"; 
document.location.href="http://www.newdomain.com"; 
window.location.reload("http://www.newdomain.com"); 
document.location.replace("http://www.newdomain.com");
In the latter case it will not be possible to return to the page that performed the redirection, since its address is erased from history, which was once needed.