IS there any benefit/effect to using NON www versus redirecting to www version?
Printable View
IS there any benefit/effect to using NON www versus redirecting to www version?
Mostly a preference thing.
Here's the code I use:
What that does is pretty much uses regex to automatically redirect anysite.com/net/org to www.anysite.com/net/orgCode:RewriteEngine On
Options +FollowSymLinks
RewriteBase /
RewriteCond %{HTTP_HOST} ^([^.]+\.(com|net|org))$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [L,R=301]
The problem with the following:
and others that use the !^www pattern variations is that if you ever have additional subdomains other than www that resolve to this address like mail.yourdomain.com or widgets.yourdomain.com then this is going to cause issues. It's much better IMO when redirecting web pages using 301 redirects in Mod_Rewrite to be as specific as you can when creating 'general' redirects (sounds like an oxymoron... I know...)Quote:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.yourdomain\.com$
RewriteRule (.*) http://www.yourdomain.com/$1 [R=301,L]
IMO the better solution is to ONLY redirect requests for http://yourdomain.com to the www version using something like:
This should be placed at the bottom of your .htaccess file in the root folder of your web so that IF the URL qualifies for another redirect, it doesn't get redirected twice. More specific redirects (like those for specific URLs) go near the top... more general redirect (like this one that redirects all non-www to www) go near the bottom.Quote:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain\.com$
RewriteRule (.*) http://www.yourdomain.com/$1 [R=301,L]