Browse Source

Redirects naked domain to www

Properly behaving websites should 301 redirect the naked domain.
James Ravn 11 years ago
parent
commit
703d356492
1 changed files with 5 additions and 1 deletions
  1. 5
    1
      roles/blog/templates/etc_apache2_sites-available_blog.j2

+ 5
- 1
roles/blog/templates/etc_apache2_sites-available_blog.j2 View File

@@ -2,7 +2,7 @@
2 2
     ServerName {{ domain }}
3 3
     ServerAlias www.{{ domain }}
4 4
 
5
-    Redirect permanent / https://{{ domain }}/
5
+    Redirect permanent / https://www.{{ domain }}/
6 6
 </VirtualHost>
7 7
 
8 8
 
@@ -24,4 +24,8 @@
24 24
     Options                 -Indexes
25 25
 
26 26
     HostnameLookups         Off
27
+
28
+    RewriteEngine on
29
+    RewriteCond %{HTTP_HOST} !^www\. [NC]
30
+    RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
27 31
 </VirtualHost>

Loading…
Cancel
Save