2
我一直在摔跤mod_rewrite規則似乎並沒有工作。簡單地說,我想以下網址: www.servername.com/showtest/1 重定向到: www.servername.com/showtest.php?id=1Mod_Rewrite規則似乎沒有與服務器查詢
我想在我的.htaccess以下應得到重定向工作:
RewriteEngine On
RewriteRule ^showevent/(\w+)/?$ showevent.php?id=$1 [L,R,QSA]
然而,它似乎並沒有工作,我在PHP的$ _GET和$ _REQUEST變量都是空的,據我所看到的。
我試圖做一些調試,包括各種不同的正則表達式。我也打開了mod_rewrite日誌來查看(我在本地服務器上工作)。這些都是相關線路:
127.0.0.1 - - [01/Nov/2011:12:25:55 +0100] [127.0.0.1/sid#b7843948][rid#b76d0058/subreq] (1) [perdir /var/www/1277/] pass through /var/www/1277/showevent.php
127.0.0.1 - - [01/Nov/2011:12:25:55 +0100] [127.0.0.1/sid#b7843948][rid#b76db058/initial] (3) [perdir /var/www/1277/] add path info postfix: /var/www/1277/showevent.php -> /var/www/1277/showevent.php/1
127.0.0.1 - - [01/Nov/2011:12:25:55 +0100] [127.0.0.1/sid#b7843948][rid#b76db058/initial] (3) [perdir /var/www/1277/] strip per-dir prefix: /var/www/1277/showevent.php/1 -> showevent.php/1
127.0.0.1 - - [01/Nov/2011:12:25:55 +0100] [127.0.0.1/sid#b7843948][rid#b76db058/initial] (3) [perdir /var/www/1277/] applying pattern '^showevent/(\w+)/?$' to uri 'showevent.php/1'
127.0.0.1 - - [01/Nov/2011:12:25:55 +0100] [127.0.0.1/sid#b7843948][rid#b76db058/initial] (3) [perdir /var/www/1277/] add path info postfix: /var/www/1277/showevent.php -> /var/www/1277/showevent.php/1
看來,而不是重寫showevents.php ID = 1,則重寫showevent.php/1
我歡迎任何幫助您可以給。
即使只是[L]作爲標誌,它也在做同樣的事情(即仍然重寫爲showevent.php/1) –
然後,也許它是Option「MultiViews」。在apache中啓用MultiViews時,如果該文件存在,「/ example」將評估爲「/example.php」。爲了測試目的,禁用它或更改重寫字或文件名。 –
「Multiviews」的確是問題所在 - 感謝修復 –