使用的.htaccess,我需要所有的请求从htaccess的,重定向所有请求到https:// WWW
http://www.domain,
http://domain,
https://domain
重定向;
https://www.domain.com
我该怎么做? 我没有任何子域名。
使用的.htaccess,我需要所有的请求从htaccess的,重定向所有请求到https:// WWW
http://www.domain,
http://domain,
https://domain
重定向;
https://www.domain.com
我该怎么做? 我没有任何子域名。
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
RewriteCond %{http_host} ^example.com [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
,将引导所有的HTTP请求https://www.example.com以及重定向到https://example.comhttps://www.example.com。
如果没有对域进行硬编码,该如何编写? – bart 2017-02-07 21:58:27
试试这个...
RewriteEngine On
RewriteBase/
RewriteCond %{HTTP_HOST} ^domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$ [OR]
RewriteCond %{HTTPS_HOST} ^domain.com$
RewriteRule ^(.*)$ "https\:\/\/www\.domain\.com\/$1" [R=301,L]
喜。首先你会在正确的地方提问。这在ServerFault上完成了。刚刚投票移交这个问题。而mod_rewrite可以做各种奇特的事情,但非www引用的是什么?只有domain.com或other.domain.com? – 0xC0000022L 2011-05-22 02:54:10
非www引用(http://domain.com)。此网站上没有子域名。 – ZaV 2011-05-22 02:58:03