Преглед на файлове

Redirects naked domain to www

Properly behaving websites should 301 redirect the naked domain.
James Ravn преди 10 години
родител
ревизия
703d356492
променени са 1 файла, в които са добавени 5 реда и са изтрити 1 реда
  1. 5
    1
      roles/blog/templates/etc_apache2_sites-available_blog.j2

+ 5
- 1
roles/blog/templates/etc_apache2_sites-available_blog.j2 Целия файл

2
     ServerName {{ domain }}
2
     ServerName {{ domain }}
3
     ServerAlias www.{{ domain }}
3
     ServerAlias www.{{ domain }}
4
 
4
 
5
-    Redirect permanent / https://{{ domain }}/
5
+    Redirect permanent / https://www.{{ domain }}/
6
 </VirtualHost>
6
 </VirtualHost>
7
 
7
 
8
 
8
 
24
     Options                 -Indexes
24
     Options                 -Indexes
25
 
25
 
26
     HostnameLookups         Off
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
 </VirtualHost>
31
 </VirtualHost>

Loading…
Отказ
Запис