patterncatcher
patterncatcher

Reputation: 275

.htaccess rewrite rule with parameters

I have a lot of urls in the following format.

index.php?option=com_letflat&task=view&id=42

index.php?option=com_letflat&task=view&task=ajaxmap

I want to rewrite all urls that contain option=com_letflat to the root of the domain, ie http://www.example.com

I have tried dozens of different things, and none seem to work. I have got as far as this:

RewriteCond %{QUERY_STRING} (^|&)option=com_letflat [NC]
RewriteRule ^index.php(.*)  http://www.example.com [R=301,L]

But it doesn't work.

Thanks

Upvotes: 1

Views: 52

Answers (1)

anubhava
anubhava

Reputation: 784918

You can use this rule:

RewriteEngine On
RewriteCond %{QUERY_STRING} (^|&)option=com_letflat(&|$) [NC]
RewriteRule ^index\.php /? [R=301,L]

Just make sure this is very first rule in your .htaccess

Upvotes: 1

Related Questions