我有一個htaccess重定向,像這樣:爲什麼使用%{query_string}的htaccess rewritecond僅在URL包含index.php時才起作用?
RewriteCond %{QUERY_STRING} tabid=53
RewriteRule . http://www.example.com/foobar? [R=301,L]
所以,當我訪問example.com/?tabid=53
沒有任何反應,example.com/index.php?tabid=53
被重定向到/foobar
。當我添加另一個條件:
RewriteCond %{REQUEST_URI} ^(.*)$
什麼都不會改變,從我的理解,這應該說「如果在URI的index.php與否並不重要」。我究竟做錯了什麼?
這是你已經設置了唯一的重寫規則?其他規則可能與它衝突。無論如何,您應該嘗試記錄mod_rewrite正在做什麼 - 請參閱rewriteloglevel指令文檔(http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriteloglevel for Apache 2.2,在2.4版中已更改) – 2014-09-02 11:06:16