问题
i use this code
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
to redirect all request to HTTPS and that is ok.
Now I want same thing except one file index810.php
when i write like this
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^ index810.php
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
i get too many redirects, any suggestions.
Thank you in advance
回答1:
A solution is to use a non rewriting rule:
# do nothing for /index810.php
RewriteRule ^index810\.php$ - [L]
# else ...
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI}
Your pattern was wrong:
- there is a space between ^ and index810.php
- %{REQUEST_URI} is all the HTTP path (ie, if at document root, it would be
=/index810.php
)
回答2:
The accepted answer didn't work for me. This did however:
RewriteCond %{THE_REQUEST} !/index810\.php [NC]
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI}
来源:https://stackoverflow.com/questions/19141216/mod-rewrite-redirect-all-to-https-except-one-file