-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
For the page Htaccess redirect to https non www I would like to add a code snippet for Htaccess redirect to https *and* www.
# Redirect http to https and add www.
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
# [NC] is a case-insensitive match
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Source: http://stackoverflow.com/a/13997498
I agree that the url looks more nice without www, but in some cases adding www is a better option. For example, if using a url without www, all cookies will be sent to all subdomains. This can slow down access to images and js/css if you use a subdomain as a cdn for static content.
More information here: http://www.yes-www.org/why-use-www/
jenstornell
Metadata
Metadata
Assignees
Labels
No labels