我有自己的沙盒/测试系统,我想将g/something
重写为g/something.php
我使用了这个非常简单的重写规则
RewriteEngine on
RewriteRule ^g/(.*?)[^\.]+ g/$1.php [L]
问题:
.php
结尾时才会触发此规则。我已尝试(^\.php)
,(!\.php)
但没有任何效果,因此我使用了[^\.]
。 错误日志:
[Sat Aug 20 15:47:53 2011] [error] [client myip] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRec
[Sat Aug 20 15:47:53 2011] [debug] core.c(3063): [client myip] r->uri = /g/..........php
[Sat Aug 20 15:47:53 2011] [debug] core.c(3069): [client myip] redirected from r->uri = /g/.........php
[Sat Aug 20 15:47:53 2011] [debug] core.c(3069): [client myip] redirected from r->uri = /g/........php
[Sat Aug 20 15:47:53 2011] [debug] core.c(3069): [client myip] redirected from r->uri = /g/.......php
[Sat Aug 20 15:47:53 2011] [debug] core.c(3069): [client myip] redirected from r->uri = /g/......php
[Sat Aug 20 15:47:53 2011] [debug] core.c(3069): [client myip] redirected from r->uri = /g/.....php
[Sat Aug 20 15:47:53 2011] [debug] core.c(3069): [client myip] redirected from r->uri = /g/....php
[Sat Aug 20 15:47:53 2011] [debug] core.c(3069): [client myip] redirected from r->uri = /g/...php
[Sat Aug 20 15:47:53 2011] [debug] core.c(3069): [client myip] redirected from r->uri = /g/..php
[Sat Aug 20 15:47:53 2011] [debug] core.c(3069): [client myip] redirected from r->uri = /g/.php
[Sat Aug 20 15:47:53 2011] [debug] core.c(3069): [client myip] redirected from r->uri = /g/64002
答案 0 :(得分:2)
^g/(.*?)[^\.]+
匹配您的替代品,因为它是例如g/test.php
g/
,然后是test.ph
,然后是p
,其中不包含.
。因此,替换会再次被替换,等等。因此,重定向溢出(请查看Apache错误日志)。
你可能想要:
^g/([^.]*?)$
因为它匹配g/
,然后匹配任何没有点的内容,然后结束网址以确保它与确切的网址匹配。