Redirect nasty multi parameter URL

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 3
Joined: 05 Jun 2013, 16:53

Redirect nasty multi parameter URL

09 Jul 2013, 19:34

Hi, I don't even know where to begin a rewrite rule with this one, or if it's even possible. Here's an example:

Code: Select all
http://www.domain.com/store/search_results.asp?txtsearchParamTxt=&txtsearchParamCat=8&txtsearchParamType=ALL&txtsearchParamMan=ALL&txtsearchParamVen=ALL&txtFromSearch=fromSearch&iLevel=2&subcat=93

I'm using a map file now for the simpler redirects, but I'd like to create a separate map file just for these and provide a new static URL to 301 them to. I don't even know what the old parameters are, so I'm going to have to go through them one by one and figure out the context of what people were trying to link to. I only have about 40, so it shouldn't take too long.

Here's one of our current rules:

RewriteMap mapfile txt:mapfile.txt
RewriteCond %{QUERY_STRING} ^product_id=(.+)$
RewriteCond ${mapfile:%1|NOT_FOUND} !NOT_FOUND
RewriteRule ^store/detail\.asp$ /${mapfile:%1}.aspx [NC,R=301,L]

Thanks in advance!
Chip

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Redirect nasty multi parameter URL

09 Jul 2013, 21:18

Did you provide the requested URL or resulting?
And what would be the issue you're struggling with? Is it capturing the names of the parameters? The values? NOt sure I understand what you're looking for.

Regards
Andrew

User avatar
Posts: 3
Joined: 05 Jun 2013, 16:53

Re: Redirect nasty multi parameter URL

10 Jul 2013, 12:15

Thanks Andrew,
I should have described my need in a more direct fashion.

So all I really want to do is redirect the above example URL and 301 redirect it to our new simple URLs like this one:

Code: Select all
http://www.domain.com/Tip-Out-Trays-C15.aspx


I don't want to, and really can't, parse out each parameter. I other words are rule that says "if you exact match this old bad dynamic URL, send it to this new static URL". I was wanting to do it in a map file, but that may not make sense.

Thanks
Chip

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Redirect nasty multi parameter URL

10 Jul 2013, 20:04

crystal clear now )))
I'd try to do this:

Code: Select all
ewriteEngine on
RewriteBase /
RewriteMap mapfile txt:mapfile.txt

RewriteCond %{QUERY_STRING} ^(.*)$
RewriteCond ${mapfile:%1|NOT_FOUND} !NOT_FOUND
RewriteRule ^store/search_results\.asp$ ${mapfile:%1}? [NC,R=301,L]


and in mapfile have this:

Code: Select all
txtsearchParamTxt=&txtsearchParamCat=8&txtsearchParamType=ALL&txtsearchParamMan=ALL&txtsearchParamVen=ALL&txtFromSearch=fromSearch&iLevel=2&subcat=93   /Tip-Out-Trays-C15.aspx


Regards
Andrew

User avatar
Posts: 3
Joined: 05 Jun 2013, 16:53

Re: Redirect nasty multi parameter URL

11 Jul 2013, 15:43

Thanks so much Andrew! Worked like a charm!

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 10 guests