user367217
user367217

Reputation: 499

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:

RewriteRule ^/?([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.

Upvotes: 2

Views: 1982

Answers (1)

Fabian
Fabian

Reputation: 13691

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

Upvotes: 1

Related Questions