我在重写方面遇到了麻烦。
到目前为止,我已经走到了这一步。
RewriteCond %{REQUEST_URI} ^/(tc|tc__|tc_activate|tcused|tcvalid)\.php$-[L]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
我有五个文件(tc.php,tc __。php,tc_activate.php,tcused.php和tcvalid.php),我不想写入https。或者更确切地说,我不希望他们受到这条规则的影响。我不知道为什么它会继续覆盖。
编辑:这是整个重写:
RewriteEngine On
RewriteBase /folderName/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /folderName/index.php [L]
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/(tc|tc__|tc_activate|tcused|tcvalid)\.php$-[L]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
答案 0 :(得分:0)
您的代码执行您不想做的事情:
RewriteCond %{REQUEST_URI} ^/(tc|tc__|tc_activate|tcused|tcvalid)\.php$-[L]
上面的行将匹配不排除所以标志是错误的,所以,使它像这样:
RewriteCond %{REQUEST_URI} !^/(tc|tc__|tc_activate|tcused|tcvalid)\.php$ [NC]
所以你的所有代码都是这样的:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/(tc|tc__|tc_activate|tcused|tcvalid)\.php$ [NC]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
注意:在测试此代码之前清除浏览器缓存
更新
RewriteEngine On
RewriteBase /folderName/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^folderName/(.*)$ /folderName/index.php [L]
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/folderName/(tc|tc__|tc_activate|tcused|tcvalid)\.php$
RewriteRule ^folderName/(.*)$ https://%{HTTP_HOST}/folderName/$1 [R=302,L]