Parcourir la source

Redirects naked domain to www

Properly behaving websites should 301 redirect the naked domain.
James Ravn il y a 10 ans
Parent
révision
703d356492
1 fichiers modifiés avec 5 ajouts et 1 suppressions
  1. 5
    1
      roles/blog/templates/etc_apache2_sites-available_blog.j2

+ 5
- 1
roles/blog/templates/etc_apache2_sites-available_blog.j2 Voir le fichier

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

Chargement…
Annuler
Enregistrer