Apache 重写url并停止重写

Apache 重写url并停止重写,apache,mod-rewrite,Apache,Mod Rewrite,我的apache web服务器将所有http通信重写为https,但有一个url(example.com/facebook/any_word)我不想重写。 我想,如果我把这个规则放在将所有http重写为https的规则之上,并在上面加上一个标志L,它就会工作。但事实并非如此。我做错了什么 .htaccess文件: RewriteRule ^/facebook/(.*)?$ /index.php/$0 [PT,L] #this rule is not applied... #...other ru

我的apache web服务器将所有http通信重写为https,但有一个url(example.com/facebook/any_word)我不想重写。 我想,如果我把这个规则放在将所有http重写为https的规则之上,并在上面加上一个标志L,它就会工作。但事实并非如此。我做错了什么

.htaccess文件:

RewriteRule ^/facebook/(.*)?$ /index.php/$0 [PT,L] #this rule is not applied...
#...other rules which rewrites http to https....

您可以启用mod_rewrite调试,以确保您认为应该发生的事情实际上正在发生。将类似于以下内容的内容放入虚拟主机配置中:

RewriteLogLevel 8
RewriteLog /var/log/rewrite.log

请注意,此语法在Apache 2.4中已更改,因此如果未运行则可能需要对其进行更改,类似的操作应该可以:

RewriteCond %{REQUEST_URI}   !/facebook     [NC]
#...other rules which rewrites http to https...

RewriteRule ^/facebook/(.*)?$ /index.php/$0 [PT,L]
我假设最后一条规则按预期运行

更新 如果最后一条规则未经测试,我建议改为:

将上述规则替换为:

RewriteRule ^/facebook/(.*)?$ /index.php/$0 [PT,L]
使用这两行代码:

RewriteCond %{REQUEST_URI} !index\.php                [NC]
RewriteRule ^facebook/(.*)/?$ /index.php/facebook/$1 [NC,L]

[L]
结束当前的重写周期–但是,当通过
.htaccess
配置重写时,将再次获取最终重写的URL并再次执行所有规则。我会尝试在执行http->https重写的规则上方使用
RewriteCond
,并为这些特定URL制定一个例外。感谢您的解释!)