Php Htaccess 301 Redirect

Thursday 27th January 2005 07:23:02 AM

For various reasons webmasters may need to move a domain name or redirect a webpage and at the same time keep thier search engine ranking; this can be done by setting up a 301 Moved Permanently redirect in either php or htaccess.

Php

Insert the following code at the top of the php file that you wish to redirect:

<?php

$redirect = "http://www.example.com";
protectedheader("HTTP/1.1 301 Moved Permanently");
protectedheader("location:$redirect"); exit();

?>


Htaccess

RewriteEngine on
Options +FollowSymlinks
RewriteRule filename.html$ /redirect_url.html [R=301,L]


A 301 redirect is vital if you are moving page as it informs robots/crawlers that a page has moved permanently and helps retain its original value.

Posted by Piniyini in Php, Htaccess

<< Php Parsing In Html   Toseef's Blog   Funny Ebay Song >>

post comments feed1 comment       Ctrl + Enter to comment
<< Php Parsing In Html   Toseef's Blog   Funny Ebay Song >>
Post a comment   Track comments
Search

Feeds (Subscribe via Google Reader)
blog posts feed Blog Posts
recent comments feed Recent Comments

Archives
2011  Sep  Oct
2010  Feb
2009  Jan  Mar  Apr  May  Jun  Jul  Oct  Nov
2008  Jan  Feb  Apr  May  Jul  Oct  Nov  Dec
2007  Jan  Feb  Mar  Apr  May  Jun  Jul  Aug  Sep  Oct  Nov  Dec
2006  Jan  Feb  Mar  May  Jun  Jul  Aug  Sep  Oct  Nov  Dec
2005  Jan  Feb  Mar  Apr  May  Jun  Jul  Aug  Sep  Oct  Nov  Dec
2004  Aug  Sep  Nov  Dec
Recent Comments
Check out my Blog Roll
/Php
/Htaccess

Says thanks to the following poeple for recently leaving a comment ...

Essay Writing Uk
Hosted Ecommerce Software
Find Online Dating
Create An Online Store
Wedding Maldives
University Essay
Write My Dissertation Uk
Buy Uk Dissertation
Dissertation Services
Masters Dissertation Uk
Dissertation Help Uk
Buy Dissertation Uk
Masters Dissertation
Professional Dissertation Service
Write My Dissertation