如何实现以下内容:
所以基本上,我的所有stream量是非www或www将被redirect到SSL www域。
编辑:
此外,我有2个工作在http上的子域名,所以我想实现上述,并保持2子域免受上述redirect规则。
您可以在Root / .htaccess中使用以下代码:
RewriteEngine on #Http to https #Exclude subdomains RewriteCond %{HTTP_HOST} !^(sub1|sub2) RewriteCond %{HTTP_HOST} ^(www\.)?example.com$ [NC] RewriteCond %{HTTPS} off RewriteRule ^ https://www.example.com%{REQUEST_URI} [NC,L,R] #add www on ssl RewriteCond %{HTTPS} on RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [NC,L,R]
这将重定向:
到ssl
第二个规则将www添加到ssl上的非www请求,重定向:
至
首先,您可以编辑您的httpd.conf
文件,并将其添加到:80个服务器
<Ifmodulee mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_HOST} ^domain.com$ [NC] RewriteRule ^(.*)$ https://www.domain.com$1 [L,R=301] </Ifmodulee>
无论如何,这个.htaccess
会做同样的事情
RewriteEngine On RewriteCond %{HTTP_HOST} !^www.domain\.com [NC] RewriteCond %{HTTP_HOST} !^$ RewriteRule ^/?(.*) https://www.domain.com/$1 [L,R,NE]
另外,你可以在你的虚拟主机文件中加入类似的东西
Redirect permanent / https://www.domain.com/
而在你的vhost_ssl中:
<Ifmodulee mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_HOST} ^domain.com$ [NC] RewriteRule ^(.*)$ https://www.domain.com$1 [L,R=301] </Ifmodulee>