mod_rewrite: redirect specific get query

Using .htaccess and mod_rewrite I want to redirect this: 

To this: [L,R=301]

My code below does NOT work:
RewriteRule ^index.php?option=com_sitemap&view=xml [L,R=301]

Open in new window

LVL 16
Who is Participating?
David S.Connect With a Mentor Commented:
RewriteRule doesn't look at the query string. To do that you need to use a RewriteCond with it.

RewriteCond %{QUERY_STRING} option=com_sitemap&view=xml
RewriteRule ^\/?index.php [L,R=301]

Open in new window

RewriteRule "^/index.php.*" site.xml [L,R=301]
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.