我有以下HTTP地址:
<?php
if(htmlentities($shop['categorie']) == '1')
{ echo "Achtergronden"; }
elseif(htmlentities($shop['categorie']) == '2')
{ echo "Widgets"; }
elseif(htmlentities($shop['categorie']) == '3')
{ echo "Overig"; }
?>
但我的HTTPS地址有一个子域名,没有www,如下所示:
http://www.example.com/
我尝试了以下规则:
https://secure.example.com/
将我发送至:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://secure.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
如何在这种情况下强制使用HTTPS?因为我需要移除www。
<小时/> 编辑:我已经将这些规则置于其上面,用于“花哨的网址”。因为我使用WordPress作为CMS:
https://secure.www.example.com/
答案 0 :(得分:1)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://secure.example.com/$1 [L,R=301]
</IfModule>
OR
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://secure.example.com/$1 [R=301,L]
这两个规则都是这样做的:任何非https请求都会重定向到https://secure.example.com,同时保留整个网址
答案 1 :(得分:1)
这应该是你完整的htaccess:
RewriteEngine On
RewriteBase /
#1--Redirect "http://domain to "https://secure"
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://secure.domain.com%{REQUEST_URI} [L,R=301]
#2--wp rules--#
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]