Apache 在http上添加www并在https上删除www
我正在努力做到以下几点: 将www添加到非安全 http://domain[.]com到http://www.domain[.]com & 在安全上删除www https://www[.]domain.com至https://domain[.]com 我正在尝试,但似乎不起作用Apache 在http上添加www并在https上删除www,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,我正在努力做到以下几点: 将www添加到非安全 http://domain[.]com到http://www.domain[.]com & 在安全上删除www https://www[.]domain.com至https://domain[.]com 我正在尝试,但似乎不起作用 RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} ^example.org$ RewriteRule ^(.*)$ http://www.example.org/$1 [
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^example.org$
RewriteRule ^(.*)$ http://www.example.org/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^example.org$
RewriteRule ^(.*)$ https://example.org/$1 [R=301,L]
试试这个:
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^example\.org$ [NC]
RewriteRule ^(.*)$ http://www.example.org/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.example\.org$ [NC]
RewriteRule ^(.*)$ https://example.org/$1 [R=301,L]
您的第二个HTTP\u主机条件仍然会检查www.
是否丢失,反之亦然