Zaheer Ahmad Khan
Zaheer Ahmad Khan

Reputation: 11

htaccess dynamic URLs redirect

Hello i want to redirect some dynamic URL to some static urls e.g

to

And

to

I tried

Redirect 301 /folder/index.php?rid=321 http ://example.com/folder/some-name-321.htm
Redirect 301 /folder/index.php?rid=324 http ://example.com/folder/some-other-324.htm

But not working. How i should redirect these URLs Also, where should i place my htaccess file. This should be in /folder/.htaccess or i should place rules in main htaccess file present in root of site.

Kind Regards

Upvotes: 1

Views: 211

Answers (1)

Amit Verma
Amit Verma

Reputation: 41219

You can never match against a Query string using Redirect (mod-alias) directive. To manipule query strings you need to use mod-rewrite the following rule in /root.htaccess

RewriteEngine on


RewriteCond %{QUERY_STRING} ^rid=(.+)$
RewriteRule ^index\.php$ http://example.com/folder/some-name-%1.htm? [NC,L,R]

Upvotes: 0

Related Questions