altmannmarcelo
altmannmarcelo

Reputation: 101

redirect with .htaccess and get parameters

Can anybody help me?

I need to redirect request with get parameters like this:

http://www.mysite.com/listings/?tx_listingcontroller[countryId]=4&tx_listingcontroller[regionId]=2868&cHash=f59c2ae1b037df6fc8a1e2a55ea0ee96

to

http://www.mynewsite.com/listings/countryId/4/regionId/2868/cHash/f59c2ae1b037df6fc8a1e2a55ea0ee96

Anybody know how can I do this?

Thanks!

Upvotes: 0

Views: 315

Answers (1)

mr_plum
mr_plum

Reputation: 2437

You can add a RewriteRule to your .htaccess file. http://httpd.apache.org/docs/current/mod/mod_rewrite.html. This uses RegEx to parse the incoming URL and redirect to a new URL based on the matched segments. Something like...

RewriteRule ^listings/?tx_listingcontroller[countryId]=(.*)&tx_listingcontroller[regionId]=(.*)&cHash=(.*)$ listings/countryId/$1/regionId/$2/cHash/$3

Upvotes: 1

Related Questions