URL query (get parameters like? Id = 5) redirecting with mod_rewrite in htaccess

advertisements

My current htaccess looks like

DirectoryIndex welcome.do index.jsp default.php index.wml homepage.php default.htm default.html index.php index.php4 index.php3 index.htm index.html index.shtml default_new_vhost.html

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

RedirectPermanent /content.asp?AUID=01 /content/
...

The redirecting doesn't work (I only get the 404 page of Wordpress). The reason are the get parameters in the URL. I tried the answers posted here. E.g.

RewriteCond %{REQUEST_URI} ^/content.asp$
RewriteCond %{QUERY_STRING} ^AUID=01$
RewriteRule ^.*$ http://www.yourdomain.com/content? [L,R=301]

Either I get a 500 error or I come to the 404 page of Wordpress. What is the correct way doing this? Than I have many entries in the form

RedirectPermanent /content.asp?pCategory=&pCountry=1&AUID=01 /content/

which is wrong, but I look for an efficient way putting this in the htaccess. Can I use something like this instead?

RewriteCond %{REQUEST_URI} ^/content.asp$
RewriteCond %{QUERY_STRING} ^pCategory=([0-9]+)&pCountry=([0-6]+)$
RewriteRule ^.*$ http://www.yourdomain.com/content? [L,R=301]


You simply do this (from my site)

rewriteCond %{QUERY_STRING} ^id=([0-9]+)$
rewriterule ^news_details.asp$ news/index.php?old_id=%1

Replace ^id with any param and simply user %1, %2 to access them in the rewrite, yours would be

rewriteCond %{QUERY_STRING} ^pCategory=([0-9]+)&pCountry=([0-6]+)$
rewriteRule ^content.asp$ /content/?category=%1&country=%2