嗨即時嘗試重寫myweb.com/ivan到一個簡單的網址。使用mod_rewrite意外的行爲
我在根目錄下有此有關的.htaccess:
RewriteEngine On
RewriteRule ^/something$ index.php?page=anunciante&anunciante=something [L,NC]
RewriteRule (.*)/?restaurantes/(.+)?$ index.php?page=anunciante&anunciante=something [L,NC]
是的,兩者是相同的。如果我嘗試進入myurl.com/ivan,我得到'未找到',但是如果我嘗試輸入myurl.com/restaurantes/something,我會進入index.php而沒有任何問題。在我的index.php我有這樣的:
print_r($_GET); die();
因此,與myurl.com/restaurantes/something我得到:
Array ([page] => anunciante [anunciante] => something)
(如預期) 但我不知道爲什麼這不是myurl工作.COM /伊萬 我也嘗試修改規則,如:
RewriteRule ^/?ivan$ index...
RewriteRule ^ivan$ index...
RewriteRule ^/ivan index...
所有沒有贏得成功。此外,我不知道在哪裏是要求「的favicon.ico」 .. 這裏是mod_rewrite的日誌: 要求myurl.com/something 日誌:http://pastebin.com/283kq3R8
要求myurl.com/restaurantes/something http://pastebin.com/5QcyuAuW
請使用是'ivan'或'something'一致。也適用於你的接受率。第三,在mod_rewrite url-paths從不以'/'開始,所以'/ something'應該只是'something'。 – Gerben 2012-03-07 16:14:50