问题
I would like to redirect all my website from http tp https except on some pages:
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
ex: pages to be excluded :
/home /user /info /mydata /ajax.php
回答1:
Add yet another RewriteCond directive:
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/(home|user|info|myta|ajax\.php)
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
or in a single rule:
RewriteCond %{HTTPS} off
RewriteRule ^/?(?!home|user|info|myta|ajax\.php) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
来源:https://stackoverflow.com/questions/43249133/htaccess-redirect-from-http-to-https-except-on-some-pages