【问题标题】:htaccess search query redirect/rewritehtaccess 搜索查询重定向/重写
【发布时间】:2018-08-11 13:16:54
【问题描述】:

我正在尝试弄清楚如何更改我的浏览器解释以下 URI 的方式:

example.com/pages/search.php?category=work_flow

进入:

example.com/search/category=work_flow

我试过了:

RewriteEngine On
RewriteRule ^/search/?$ /pages/search.php [L]

但它不起作用。我对 Htaccess 没有太多经验,所以我也很感激解释。

谢谢

编辑:我的问题似乎不够清楚

【问题讨论】:

标签: php .htaccess redirect


【解决方案1】:

你要的是这样吗?

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]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多