我总是使用以下规则来pipe理url:
Options +FollowSymLinks RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^.*$ ./urlredirect.php
有了这个,我可以轻松地检查用户试图访问哪个网页。
现在我有一个网站,需要在所有网页上的https。 这是基本的解决scheme:
RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
我现在的问题是,我不能同时工作。 我对mod重写和正则expression式知之甚less。
任何帮助将不胜感激。
从Apache文档:HTTP到HTTPS https://wiki.apache.org/httpd/RewriteHTTPToHTTPS
所以你需要有条件的,然后是每个规则。
Options +FollowSymLinks RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^.*$ ./urlredirect.php RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}