HTTP Error 301: Permanent Redirect
After reading many discussion about "www." is deprected, I visit many sites and the most of them use the "www." in the domain name. At this point I decide that the request to http://aadmm.org should permanetly redirect to http://www.aadmm.org, but how do I implement this?
Changes in the .htaccess file
On my web server I must do following, that the request to http://aadmm.org is permanently redirect to http://www.aadmm.org.
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.aadmm\.org$ [NC]
RewriteRule ^(.*)$ http://www.aadmm.org/$1 [R=301,L]
The [R=301,L] means redirect the client and send a 301 status code (R=301) and make this the last rule (L).
And the other way?
Change the .htaccess file to following, if you will have that all requests from http://www.aadmm.org will go to http://aadmm.org.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.aadmm\.org$ [NC]
RewriteRule ^(.*)$ http://aadmm.org/$1 [R=301,L]
Useable for:
- directories
- files