Переглянути джерело

Redirects naked domain to www

Properly behaving websites should 301 redirect the naked domain.
James Ravn 10 роки тому
джерело
коміт
703d356492

+ 5
- 1
roles/blog/templates/etc_apache2_sites-available_blog.j2 Переглянути файл

@@ -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>

Завантаження…
Відмінити
Зберегти