1
我有自己的沙盒/測試系統,我想重寫g/something
到g/something.php
爲什麼這個簡單的重寫降到500服務器錯誤?
我用這個很容易重寫規則
RewriteEngine on
RewriteRule ^g/(.*?)[^\.]+ g/$1.php [L]
問題:
- 我怎麼能否定我的規則? (這意味着,當請求的文件不與
.php
結束此規則纔會觸發。我已經試過(^\.php)
,(!\.php)
但是毫無效果,所以我用[^\.]
。 - 爲什麼這條線拋出500內部服務器錯誤?
錯誤日誌:
[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
1.我怎樣才能否定不使用[]但具有()正則表達式? 2.這可能是如何工作的? – genesis
否定:http://wiki.apache.org/httpd/RewriteRule。所以'!^ ... $'。該解決方案的工作原理是因爲替換*不*再匹配正則表達式。 – pimvdb
謝謝。當我想重寫g/test/2到g/test-2.php時,我會用什麼? – genesis