我已经使用 htaccess 强制所有页面使用...重新路由到 https
RewriteEngine on
RewriteBase /
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://ourdomain.com/$1 [R,L]
有什么方法可以为 ourdomain.com/videos && ourdomain.com/blog 撤销该规则,确保这些页面被迫放弃 https 并使用 http?
最佳答案
您已经完成了使用 RewriteCond
将重写限制为端口 80 上的请求的部分。
您不想为 /videos
和 /blog
重写端口 80 上的请求,因此:
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/videos
RewriteCond %{REQUEST_URI} !^/blog
RewriteRule ^(.*)$ https://ourdomain.com/$1 [R,L]
并且您想在端口(大概)443 上重写对这些 URL 的请求:
RewriteCond %{SERVER_PORT} 443
RewriteRule ^/((videos|blog)/.*) http://ourdomain.com/$1 [R,L]
关于php - 如何使用 .htaccess 将所有页面重定向到 https,但有异常(exception)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10475356/