Code Redirects

Posted In : Uncategorized

HTML Single File Redirect Redirect 301 /olddirectory/oldfile.html Directory Redirect in Apache RewriteEngine On RewriteRule ^olddir/(.*)$$1 [R=301,L] OR Redirect 301 /olddirectory .html to .php in .htaccess Options +FollowSymLinks rewriteEngine on rewriteRule ^(.+).htm$ /folder/$1.php [L] 40? Redirects ErrorDocument 404 /index.html ErrorDocument 403 /index.html ErrorDocument 401 /index.html JSP Redirect <%
response.setStatus(301); response.setHeader( “Location”, “” ); response.setHeader( “Connection”, “close” );
%> .NET Redirects <script runat=”server”> private void Page_Load(object sender, System.EventArgs e) {
Response.Status = “301 Moved Permanently”; Response.AddHeader(“Location”,””);
} </script> Redirect in ASP <%@ Language=VBScript %> <%
Response.Status=”301 Moved Permanently”; Response.AddHeader(“Location”,””);
%> Simple PHP Single File Redirect <?
Header( “HTTP/1.1 301 Moved Permanently” ); Header( “Location:” );
?> Cold-Fusion Redirect <.cfheader statuscode=”301″ statustext=”Moved permanently”> <.cfheader name=”Location” value=””> Redirect in IIS In internet Services Manager, right click on the file or folder you wish to redirect. Select the radio button called “a redirection to a URL”. Enter the redirection page. Check “The exact url entered above” and the “A permanent redirection for this resource”. Then Click on ‘Apply’ and that should do it. CGI Perl Redirect $q = new CGI; print $q->redirect(“”); New Domain (mod_rewrite) Options +FollowSymLinks RewriteEngine on RewriteRule ^(.*)$$1 [R=301,L] *Contact your backlinks to modify to the new domain name. www to no www Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^ [NC] RewriteRule ^(.*)$$1 [L,R=301] *This will ensure that all requests coming in to will get redirected to

One Response to “Code Redirects”

  1. Joshua Harwood on 11 Jul 2008 at 11:30 am

    I find this code redirect page very helpful. I have to check it everytime I need to make a redirect.

Trackback URI  |  Comments RSS

Leave a Reply