2012-05-10 78 views
0

我有這樣一個網址:.htaccess替換url?

localhost/site/index.php?option=com_cust&tool=edit 

,我想換成index.php?option=com_cust&tool=editedit。這可能嗎?我所做的嘗試不起作用,例如:

RewriteEngine On 
RewriteRule ^index.php?option=com_cust&tool=edit localhost/site/edit [L,QSA,R=301] 
+0

可能的重複:[htaccess重寫爲查詢字符串](http://stackoverflow.com/questions/1231067/htaccess-rewrite-for-query-string) – Zuul

+0

可能的重複:[how-to -change-URL查詢字符串與 - PHP-htaccess的(http://stackoverflow.com/questions/9528728/how-to-change-url-query-string-with-php-htaccess) – Zuul

+1

你可以閱讀關於htaccess技巧和技巧[這裏](http://corz.org/serv/tricks/htaccess2.php?page=1),並找到一些非常有用的信息! – Zuul

回答

1
RewriteRule ^site/edit site/index.php?option=com_cust&tool=edit [L] 

你弄錯了 - 什麼重寫模塊的作用是它需要什麼,用戶在輸入(在這種情況下,「編輯」),並把它轉換成你的服務器可以理解(加載index.php並將一堆變量傳遞給它)。

而且,你絕對不希望外部重定向,更不用說301重定向。 'L'應該是您在這裏需要的唯一標誌。

+0

嗨,謝謝你的幫助,並解釋。我應用了規則,但url仍然沒有改變?我有選項+ FollowSymlinks和RewriteEngine集,所以我不知道爲什麼它不工作? –

+0

沒問題 - 你有AllowOverrides所有也設置?嘗試在你的.htaccess文件中插入一些隨機字符,看看它是否會拋出500錯誤。 – Ansari

+0

是的,我已經在我的httpd中設置了它,並且隨機字符也在網站上引發了500錯誤。 –