我想将任何不安全的请求重定向到https,并确保该网址始终使用' www'。这就是我所拥有的,但似乎并不起作用。我错过了什么?
Options +FollowSymLinks RewriteEngine On RewriteCond %{HTTP_HOST} ^domain.com [NC] RewriteCond %{HTTP_HOST} ^www.domain.com [NC] RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301]
答案 0 :(得分:3)
您可以使用:
foreach
答案 1 :(得分:0)
## Redirecting HTTP to HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
## Redirecting non WWW to WWW
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.tld$ [NC]
RewriteRule ^(.*)$ http://www.domain.tld/$1 [R=301,L]