我试图弄清楚如何更改浏览器解释以下URI的方式:
example.com/pages/search.php?category=work_flow
进入:
example.com/search/category=work_flow
我尝试过:
RewriteEngine On
RewriteRule ^/search/?$ /pages/search.php [L]
但是它不起作用。我在Htaccess方面没有太多经验,所以我也希望能进行移栽。
谢谢
编辑:我的问题似乎不够清楚
答案 0 :(得分:2)
您要这样吗?
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Example 1: detail search page
RewriteRule ^search$ /pages/search.php [NC,L,QSA]
# Example 2 - search with in the category: example.com/search/category
RewriteRule ^search/(.*)$ /pages/search.php?type=$1 [NC,L,QSA]
# Example 3: example.com/search/category/work_flow
# or example.com/search/user/work_flow
RewriteRule ^search/(.*)/(.*)$ /pages/search.php?type=$1&work=$2 [NC,L,QSA]