在Apache的httpd.conf文件中,如何重写模块以使url的www为非www并强制http为https? 当我在下面尝试时,它会变成无限重定向错误
RewriteCond %{HTTP_HOST} ^www.(.*)$
RewriteRule ^(.*)$ https://example.com$1
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^(.*)$ https://example.com$1
或
RewriteCond %{HTTP_HOST} ^www.(.*)$ [OR]
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^(.*)$ https://example.com$1
答案 0 :(得分:0)
要从www / http重定向到非www / https,您可以使用:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\. [OR]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://example.com%{REQUEST_URI [NC,L,R]