Pavel Nikolaev
Pavel Nikolaev

Reputation: 329

.htaccess Rewrite Query String

I have troubles redirecting query strings and I really can't find a way how to do it. Let me be more specific: I want to achieve the following: Redirect http://blablabla.com/default.asp?Kategori=1&Valg=77 to: http://blablabla.com/default_Kategori_1_Valg_77.html

Any help will be very appreciated. Kind Regards, Pavel Nikolaev

Upvotes: 1

Views: 68

Answers (2)

Pavel Nikolaev
Pavel Nikolaev

Reputation: 329

I would like to provide a new version of what starkeen advised me:

RewriteEngine on
RewriteCond %{QUERY_STRING} ^Kategori=(.*)&Valg=(.*)$ [NC]
RewriteRule ^default\.asp$ http://blablabla.com/default_Kategori_%1_Valg_%2.html? [L,R]

The difference is that know I am catching the values of the Kategori and Valg parameters and use them in the new URL. Really interesting! Thank you all.

Upvotes: 1

Amit Verma
Amit Verma

Reputation: 41219

This should work :

RewriteEngine on
RewriteCond %{QUERY_STRING} ^Kategori=1&Valg=77$ [NC]
RewriteRule ^default\.asp$ http://blablabla.com/default_Kategori_1_Valg_77.html? [L,R]

Upvotes: 1

Related Questions