PHP & SEO – Permanent redirect using PHP header – HTTP 301
Permanent redirects are an important tool not only for general PHP development but also for Search Engine Optimisation. To a general user the browser simply forwards on to the new URL, probably without you even noticing. To search engine crawlers they are also forwarded but provided extra information that the page they are visiting has permanently moved to the new address. If this was Google for example, Googlebot would notice the change and drop the old URL from it’s index and begin indexing the new one.
So, what’s the point in a 301 permanent redirect and how does it differ to a standard redirect? If you needed to change the way a URL is structured from, for example, index.php?page=1 (very non-SEO friendly) to /web-development-gloucestershire/ (SEO friendly) then you can inform search engines of the change. Without the permanent redirect the first page will either fail and produce a ’404 Not Found’ or be identical to the new page – thus causing duplicate content issues.
The permanent redirect differs from a standard redirect because of the way it is informing search engines of the change. Without this it would become a temporary redirect or standard redirect. This means that search engines will keep the original page in it’s index because it is expecting the redirect to be removed at some point soon.
To create a 301 permanent redirect in PHP you use the following two lines of code, it’s really that easy.
<?php
header('HTTP/1.1 301 Moved Permanently');
header('http://rosstanner.co.uk/');
?>
Remember, this must be placed at the very top of the script. More specifically, before any HTML content or output is produced. This is because PHP uses the headers, which are called before any output, in order to complete the redirect.
Is there a limit on how many 301 redirects I can use on my website?
In short the answer is no, there isn’t a limit. However there is a limit on ‘chained redirects’ as Matt Cutts from Google explains.
If you are running an Apache server you can achieve this using .htaccess too. If you don’t have access to edit this file within your online files then consult your webmaster.
-
Latest FIFA 12 Results
- WIN - Real Madrid 0-1 FC Barcelona
- WIN - Real Madrid 2-4 FC Barcelona
- WIN - Real Madrid 1-3 FC Barcelona
- DRAW - FC Barcelona 1-1 FC Barcelona
- WIN - Arsenal 1-3 FC Barcelona
- LOSS - FC Barcelona 4-1 FC Barcelona
- DRAW - Real Madrid 2-2 FC Barcelona
- LOSS - Real Madrid 4-3 FC Barcelona
- WIN - FC Barcelona 3-4 FC Barcelona
- LOSS - FC Barcelona 2-1 FC Barcelona
FORM - Last 10
- W5 D2 L3View more stats
Tags
aggregator codeigniter computer css database developer development facebook fifa fifa 12 football framework freelance google html iPad jquery lamp linux membership system Motherboard mysql myvouchercodes open source php php tutorial resources rossytzoltan rss search engine optimisation seo social media tech forum the guardian tutengine tutorial tutorial search engine tweet twitter ubuntu user system wamp web developer web developer twitter zendTwitter
- @chris86phillips @jedda10b @matchavystokes @olliey10 @craigydibs @apperleyshane @mattboucher12 @djsijames hahaha jedder wtf lol 6 hours ago
- @chris86phillips @jedda10b @matchavystokes @olliey10 @craigydibs @apperleyshane @mattboucher12 @djsijames hahaha! Whos got the gun? 6 hours ago
- @janknight4 im sorry Jan i love you really! Gwaaaaaaan jan 7 hours ago
- @janknight4 my bra strap is stuck on my arm 7 hours ago
- @jan 7 hours ago








