소스 검색

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,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…
취소
저장