www or not www. what are the best practices?
what are the best practices regarding handling names with and without www?
1) redirect requests from
2) redirect requests from example.com/anything to
I chose to use the Apache web server. Should i consider using mod_rewrite (RewriteCond / RewriteRule)?
Thanks!
7 Replies
@JshWright:
I don't bother redirecting. Let the user use whichever they want.
Ditto. Just have the same virtualhost answer both
Edit: if you accept both, just remember to always set domain-level cookies. If you set a cookie for
@glg:
@JshWright:I don't bother redirecting. Let the user use whichever they want.
Ditto. Just have the same virtualhost answer both
Actually I was told years ago that redirecting might be the proper solution to avoid content duplication penalties from search engines. So I usually redirect.
Doing this to the www or the non-www version is usually up to my clients' requests or the domain name (e.g. whichever 'sounds' better).
I decided to rewrite to example.com w/o www.
My config looks as follows:
<virtualhost example.com:80="">ServerName example.com
ServerAlias www.example.com
DocumentRoot "/var/www/sites/example.com/current/public"
ErrorLog "/var/log/apache2/example.com-error_log"
CustomLog "/var/log/apache2/example.com-access_log" common
<directory "="" var="" www="" sites="" example.com="" current="" public"="">Options All
AllowOverride All
Order allow,deny
Allow from all</directory>
RewriteEngine On
# Remove the www
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^/(.*)$ http://example.com/$1 [L,R=301]</virtualhost>