我想redirect访问从http到https的url只有我的网站几页。
我知道如何使用Apache虚拟主机中的重写整个网站:
RewriteEngine On RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteRule (.*) https://%{SERVER_NAME}%{REQUEST_URI}
但有没有办法做到这一点的网站页面? 例如“www.example.com/protected-page”
尝试这个
RewriteRule ^/protected-page/(.*) https://example.com/protected-page/$1 [R,L]
参考: http : //httpd.apache.org/docs/current/rewrite/intro.html
我最终做了一些不同的事情,并且保护了一切, 但是一个页面在被保护的时候不起作用:
RewriteEngine On RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteCond %{REQUEST_URI} !^(.*loadFormImages.*) RewriteRule (.*) https://%{SERVER_NAME}%{REQUEST_URI} [L] #RewriteLog /opt/tmp/rewrite.log #RewriteLogLevel 3