我有兩個網址,我正在嘗試重寫,過去... 4-5小時(現在頭痛)。Htaccess將GET請求重寫爲另一個GET請求,另一個GET GET請求使用2個GET變量
我試圖改寫
/arts/tag/?tag=keyword
到
/search/art?keywords=keyword
看着其他的問題,我制定了我重寫這樣
RewriteRule /arts/tag/?tag=([^&]+) search/art?keywords=$1 [L,R=301,NC]
和
RewriteRule ^arts/tag/?tag=$ /search/art\?keywords=%1? [L,R=301,NC]
我嘗試了反斜槓,沒有,沒有運氣。
也試過
RewriteCond %{QUERY_STRING} /arts/tag/?tag=([^&]+) [NC]
RewriteRule .* /search/art\?keywords=%1? [L,R=301,NC]
第二個是類似的,
/arts/category?id=1&sortby=views&featured=1
到
/art/moved?id=1&rearrange=view
我改變得變量名是我自己學習的原因目的,因爲我沒有找到任何教程爲我的目的。由於類別已更改,我還將類別更改爲移動,並且我必須在內部重定向某些ID#。
RewriteCond %{QUERY_STRING} id=([^&]+) [NC] // I need the path in there though, not just query string, since I'll be redirecting /blogs/category and /art/category to different places.
RewriteRule .* /art/moved/id=%1? [L,R=301,NC]
任何幫助將不勝感激。謝謝。
當追加到查詢字符串時,應該使用'QSA'作爲'RewriteRule'的標誌(QSA代表「Query String Append」)。 – fge
謝謝,我會給它一個鏡頭。 – Darius
像這樣? RewriteRule/arts/tag /?tag = $/search/art?keywords = $ 1 [QSA,NC],仍然沒有。我試着在上面發佈的所有代碼中實施QSA,而不僅僅是那一個。 – Darius