2013-10-25 17 views
0

我重寫通過.htaccess進行 網址我想重寫網址:需要幫助重定向301個htaccess的(我不能所有主題中找到)

abc.com/index.php?mod=products&cat=mu&pid=0&cid=26<br/> 

abc.com/san-pham/mu-0-26.html 

我使用如下代碼

RewriteRule ^san-pham/(\.*)-(\.*)-(\.*)\.html$ index.php?mod=products&cat=$1&pid=$2&cid=$3 [R=301,L] 

當點擊到URL abc.com/san-pham/mu-0-26.html,其中301重定向到abc.com/index.php?mod=products&cat=mu&pid=0&cid=26

但我想abc.com/index.php?mod=products&cat=mu&pid=0&cid=26重定向301 abc.com/san-pham/mu-0-26.html

有人幫幫我嗎?
非常感謝你。

回答

0

擺脫你所擁有的規則中的R=301。你想要內部重寫而不是外部重定向。然後加上:

RewriteCond %{THE_REQUEST} \ /index\.php\?cat=([^&]+)&pid=([^&]+)&cid=([^&\ ]+) 
RewriteRule^/san-pham/%1-%2-%3.html? [L,R=301] 
+0

謝謝Jon Lin!這是完美的工作。 –