All my incoming http://
traffic is changed to https://www.example.com
i want to enable http
for specific file request eg. http://www.example.com/crossdomain.xml
below is my current rewrite rule: -
RewriteEngine On
# change https to http for specific file called "crossdomain.xml"
RewriteCond %{REQUEST_URI} ^/crossdomain.xml
RewriteRule ^/?(.*) http://%{SERVER_NAME}/crossdomain.xml
# change https to http for specific url/dir access called "/speedtest/"
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} ^/speedtest
RewriteRule ^/?(.*) http://%{SERVER_NAME}%/speedtest [L,R=301]
#rewirte all traffic to https excepth the /speedteset and /crossdomain.xml
RewriteCond %{HTTPS} !on
RewriteCond %{REQUEST_URI} !^/speedtest/
RewriteCond %{REQUEST_URI} !^/crossdomain.xml
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
Thank you
答案 0 :(得分:1)
将RewriteCond%{HTTPS}添加为ON后,重写规则有效
RewriteEngine On
RewriteCond %{HTTPS} ON #added this condition to get it working
RewriteCond %{REQUEST_URI} ^/crossdomain.xml
RewriteRule ^/?(.*) http://%{SERVER_NAME}/crossdomain.xml
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} ^/speedtest
RewriteRule ^/?(.*) http://%{SERVER_NAME}%/speedtest [L,R=301]
RewriteCond %{HTTPS} !on
RewriteCond %{REQUEST_URI} !^/speedtest/
RewriteCond %{REQUEST_URI} !^/crossdomain.xml
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]