什么正则表达式应该代表“所有不跟在‘index.php’之后的东西都应该指向‘index.php/$1’”?
例如,“http://mysite/moo”应该指向“http://index.php/moo”,而“http://index.php/moo”不应该。
我目前正在使用 PCRE 正则表达式(Apache 文档说应该在此处使用 PCRE)无效:RedirectMatch (?<=index\.php)(\/.+) /index.php/$1
.
什么是正确的?
UPD:重点是只使用 mod_alias,省略 mod_rewrite
最佳答案
您可以使用 RedirectCond
具有不匹配的模式(“!”前缀)。尝试:
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule (.*) index.php/$1
或者:
RewriteCond $1 !^/?index.php
RewriteRule (.*) index.php/$1
关于regex - Apache 重定向正则表达式 : match something that is not following something,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7084048/