开发者

mod_rewrite: rewrite specific URL

I want to rewrite a specific URL, I'll show an example so you'll understand what I mean.

First, my current rewrite rule:

Re开发者_StackOverflowwriteRule ^/?([a-zA-Z0-9/-]+)/?$ /index.php [NC,L]

Now I want this URL:

http://example.tld/foobar?test

Rewritten to:

http://example.tld/foobar

Note: only for /foobar?test! E.g. not for /somethingelse?test and also not for /foobar?blah!

Thanks in advance!

EDIT: I realized I want a 301 redirect from /foobar?test to /foobar, not a "traditional" rewrite. Hope that is possible.


RewriteCond %{QUERY_STRING}    ^test$
RewriteRule ^/foobar$          /foobar      [NC,R=301,L]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜