/ Published in: HTML
You must use Google friendly domain redirect in these cases:
You changed a domain name for your web page and want the old one to redirect visitors to a new one.
You have many domains for your website (one primary and many alternative).
You want to strip the ‘www’ part from the domain name.
How to redirect?
For case #1 and #2 you must point (alias) all the domains to the same website. Ask your server administrator or hosting providers how to do that. Some times hosting providers call this – domain parking.
Select configuration for desired case below. Replace domain names with your real ones and paste the code to file named ‘.htaccess’. Upload the file it into the root folder of your web page.
You changed a domain name for your web page and want the old one to redirect visitors to a new one.
You have many domains for your website (one primary and many alternative).
You want to strip the ‘www’ part from the domain name.
How to redirect?
For case #1 and #2 you must point (alias) all the domains to the same website. Ask your server administrator or hosting providers how to do that. Some times hosting providers call this – domain parking.
Select configuration for desired case below. Replace domain names with your real ones and paste the code to file named ‘.htaccess’. Upload the file it into the root folder of your web page.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
Configuration for case #1 RewriteEngine On RewriteBase / # redirects old domain to a new one RewriteCond %{HTTP_HOST} ^www\.olddomain\.com$ RewriteRule ^.*$ http://www.newdomain.com%{REQUEST_URI} [R=301,L] Configuration for case #2 RewriteEngine On RewriteBase / # redirects any alternative domain which name isn't "www.primarydomain.com" RewriteCond %{HTTP_HOST} !^www\.primarydomain\.com$ RewriteRule ^.*$ http://www.primarydomain.com%{REQUEST_URI} [R=301,L] Configuration for case #3 RewriteEngine On RewriteBase / # strips the "www" RewriteCond %{HTTP_HOST} ^www\.domain\.com$ RewriteRule ^.*$ http://domain.com%{REQUEST_URI} [R=301,L]
URL: http://www.webtoolkit.info/google-friendly-domain-redirect-using-apache-rewrite.html