1
請幫助我使用htaccess從帶有參數的子目錄重寫到另一個目錄。編輯:我應該注意,該參數將來自用戶輸入,所以我需要一個通配符的關鍵字是。在.htaccess子目錄中重寫查詢參數
從 http://www.example.com/search/node?find=keyword
要 http://www.example.com/search/node/keyword
請幫助我使用htaccess從帶有參數的子目錄重寫到另一個目錄。編輯:我應該注意,該參數將來自用戶輸入,所以我需要一個通配符的關鍵字是。在.htaccess子目錄中重寫查詢參數
從 http://www.example.com/search/node?find=keyword
要 http://www.example.com/search/node/keyword
可以在/root.htaccess使用以下規則:
RewriteEngine on
#1)Redirect "/search/node/?find=foo" to "/search/node/foo"#
RewriteCond %{THE_REQUEST} /search/node/?\?find=([^\s]+) [NC]
RewriteRule^/search/node/%1? [NC,L,R]
#2)internally redirect "/search/node/foo" to "/search/node/?find=foo"#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^search/node/(.+)$ /search/node/?find=$1 [QSA,NC,L]
這將內部重定向/搜索/節點/富到/search/node /?find = foo。
請看我的例子,我在尋找相反的東西。從參數到清潔版本 – Haz
@哈茲請參閱編輯的版本 – starkeen
謝謝,你真棒!一直試圖找出這6個小時以上。 – Haz