我有两个域指向同一个地方,但我只希望其中一个域将所有http请求重定向到https。
http://thisisme.mydomain.com需要重定向到https://thisisme.mydomain.com
作为额外规则,我需要确保http://thisisme.mydomain.com/health_check.php不会重定向。
这是我到目前为止所拥有的。
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
# Don't redirect /heath_check.php to https
RewriteCond %{REQUEST_URI} !(health_check\.php)$
#This line needs looking at! Should only redirect any xxx.mydomain.com requests to https
RewriteCond %{HTTP_HOST} mydomain\.com
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
# block hidden directories
RewriteRule "(^|/)\." - [F]
# This makes the url look pretty for codeigniter...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
</IfModule>
EDIT!
如果请求的域名不是mydomain.com,我实际上需要做相反的事情 - 它需要重定向到http是请求https
答案 0 :(得分:0)
要排除RewriteEngine on
,请将以下条件放在http=>https
以下RewriteCond %{HTTP_HOST} !^(www\.)?thisisme\.com$ [NC]
行或{{1}}规则之上:
{{1}}