mod_rewrite删除查询并保留字符串

时间:2016-11-16 00:50:30

标签: apache .htaccess mod-rewrite

简单的问题(我希望)。 我需要从url中删除查询并重写它只保留字符串。

示例:

http://example.com/photography/?c=events

最终结果应该是:

http://example.com/photography/events

1 个答案:

答案 0 :(得分:0)

怎么样:

RewriteEngine on

# capture the value of c parameter of the query string (as %1)
RewriteCond %{QUERY_STRING} (?:^|&)c=([^&]+)
RewriteRule ^photography/$ $0%1? [L]

相关问题