The perfect 301 htaccess 404 redirect template. This custom .htaccess file will re-direct domain.com to www.domain.com it will also create a custom 404 error page it will create a redirect for domain.com/index.html to www.domain.com and will create custom redirects for old pages to new pages. Create a file called .htaccess and paste in the code bellow. This all encompassing .htaccess file will:
- Redirecting domain.com to www.domain.com will conform to website Cannonicalization Standards by focusing all traffic to a single website domain URL, by having both forms of a website domain URL available you are essentially splitting traffic in the SERPs between them.
- Redirecting the homepage /index.html back to the top level website domain URL will also aid with Cannonicalization by focusing both types of homepage backlinks to the same URL.
- A custom 404 Error page will help with lowering the website bounce rate by salvaging broken backlink traffic and refocusing it to a targeted lost traffic landing page (can use either the homepage or a custom 404 page, but the latter is preferred for targeted traffic management).
- Using 301 Redirects help preserve backlink juice off of old links that have changed to a new page but you do not want loose traffic.
Please paste this code into your .htaccess file:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html$ http://www.domain.com/$1 [R=301,L]
ErrorDocument 404 http://www.domain.com/custom-error-page.html
Redirect 301 /oldpage1.html http://www.domain.com/newpage1.html
Redirect 301 /oldpage2.html http://www.domain.com/newpage2.html
Redirect 301 /oldpage3.html http://www.domain.com/newpage3.html
Redirect 301 /oldpage4.html http://www.domain.com/newpage4.html
Redirect 301 /oldpage5.html http://www.domain.com/newpage5.html
Redirect 301 /oldpage6.html http://www.domain.com/newpage6.html
Redirect 301 /oldpage7.html http://www.domain.com/newpage7.html
Redirect 301 /oldpage8.html http://www.domain.com/newpage8.html
Redirect 301 /oldpage9.html http://www.domain.com/newpage9.html







2 comments on "301 htaccess 404 custom redirect example: Complete .htaccess URL Cannonicalization template"
Subscribe in a Reader
So you have to supplant your URL's where ever it says http in the .htacces like this right? http://www.sitemagnify.com/landing-page and use the subdomain /landing-page-roi for example for the 301's of direct pages? Just want to make sure let's say your redirecting to a PHP site does all of this apply? Finally what if your content changes on a page you redirect from, like from a contact us to an about us page will that confuse the SERPS because the link may be less relevant? In that case should you only redirect to something similar to your original conent?
Many thanks for your post on how to redirect.
For more ideas and info on redirecting I have added some usefull tips on my blog http://www.spanglishwebs.com/blog/archives/196
Many thanks
Rachel
Post a Comment