Redirecting www to non-www using .htaccess
| SHARE: | Share |
|
Some people like www, some not. I recommend to use only one of the versions, www or non-www.
Here are some codes you can add to your .htaccess file to set up the friendly (301) redirects.
Redirect www to non-www:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]
Redirect non-www to www:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]
None of these versions is better than the other. It is a matter of… I dunno… taste?
I like to use the www one if my domain name is a short one, if it is longer, I use the none-www one.
Was this post useful? Buy me a beer.
Incoming search terms:
- www thoughtsofjs com (6)
- powered by myBB name generator (6)
- powered by myBB the game of love lyrics (4)
- powered by SMF the game of love lyrics (4)
- powered by SMF 2 0 beer cycling jerseys (4)
- powered by SMF modern art museum (3)
- powered by SMF what is the definition of modern art (2)
- powered by SMF names of famous people (2)
- powered by myBB domain name registration (2)
- powered by SMF nature magazine (1)
Filed under: Web development