1
我對mod_rewrite有問題。mod_rewrite/foo到/index.php?id=foo AND/foo/foo2到/index.php?id=foo/foo2
我想在標題中重定向這些URI。我用下面的規則
RewriteEngine on
RewriteCond $1 !^(folders not to be redirected e.g. css|images)
RewriteCond $1 !^(.*).(file extension e.g. png|css|txt|php)
RewriteRule ^(.*)$ index.php?id=$1 [L]
,如果我把所有的資源文件夾中,只工作,否則它會告訴我:
"/foo/index.php" not found.
所以要解決,我把所有的資源文件夾中「www」
但是,當我嘗試從例如子文件夾加載資源「富」它告訴我:
The requested URL "/foo/foo2" was not found on this server.
我如何可以加載資源來自像「/富/ foo2的」,甚至是「/富/ foo2的/ foo3」子文件夾?
我該如何解決這個問題,在文件夾中自動搜索index.php?
你說得對。我不想在最後追加那些醜陋的尾部斜線。但是如何刪除它們或在沒有它們的情況下重寫? – 2013-04-28 16:10:04
@JuliusRickert,我添加了另一個選項,沒有結尾的斜槓。 – 2013-04-28 16:23:59
我認爲「[NC]」是不需要的,但是「[L]」必須在那裏。我對嗎? – 2013-04-28 20:16:55