How to avoid a file to redirect

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 13
Joined: 21 May 2015, 17:54

How to avoid a file to redirect

21 May 2015, 18:33

I want avoid the files under the products, e.g.

RewriteEngine on
RewriteBase /
RewriteMap mapfile txt:mapfile.txt
RewriteMap revmapfile txt:revmapfile.txt
RewriteCond %{QUERY_STRING} (.+) [NC]
RewriteRule ^(.*)products/projectinfopage.aspx$ http://www.abc.com/$1products/${mapfile:%1}? [NC,R=301,L]
RewriteRule ^(.*)products/(.*)(?!.*(?:\.)).* $1products/productinfopage.aspx?${revmapfile:$2} [NC,L]

But the products/find-a-product.aspx, products/allitems.aspx aslo will redirect.
can I exlcude the "." for Links to avoid the files to redirect?

User avatar
Posts: 13
Joined: 21 May 2015, 17:54

Re: How to avoid a file to redirect

22 May 2015, 11:32

and btw,How can just match a querystring parameter. eg.

http://www.abc.com/products/product.asp ... =1&type=xy
SEO to http://www.abc.com/products/prodcutname?type=xy
the revert to
http:// http://www.abc.com/products/product.asp ... =1&type=xy

RewriteEngine on
RewriteBase /
RewriteMap mapfile txt:mapfile.txt
RewriteMap revmapfile txt:revmapfile.txt
RewriteCond %{QUERY_STRING} (.+) [NC]
RewriteRule ^(.*)products/product.aspx$ http://www.abc.com/$1products/${mapfile:%1}? [NC,R=301,L]
RewriteRule ^(.*)products/(.*)(?!.*(?:\.)).* $1products/productinfopage.aspx?${revmapfile:$2} [NC,,QSA,L]

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: How to avoid a file to redirect

24 May 2015, 08:22

Hello,

To exclude ".", please use the following structure [^.].
I've also added you the part to match the "type" parameter which you want to leave:

RewriteEngine on
RewriteBase /
RewriteMap mapfile txt:mapfile.txt [NC]
RewriteMap revmapfile txt:revmapfile.txt [NC]
RewriteCond %{QUERY_STRING} ^(.+(type=.+))$ [NC]
RewriteRule ^(.*)products/product\.aspx$ http://www.abc.com/$1products/${mapfile:%1}\?%2 [NC,R=301,L]
RewriteRule ^(.*)products/([^.]*)$ $1products/product.aspx?${revmapfile:$2} [NC,L]

User avatar
Posts: 13
Joined: 21 May 2015, 17:54

Re: How to avoid a file to redirect

24 May 2015, 13:12

if the URL don't include the paramter "type", can I remove the last "?" from the SEO url?

Thanks,
Gan

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: How to avoid a file to redirect

26 May 2015, 05:35

Hello, Gan

>if the URL don't include the paramter "type", can I remove the last "?" from the SEO url?

Yes, please fix the rules like this:

RewriteEngine on
RewriteBase /
RewriteMap mapfile txt:mapfile.txt [NC]
RewriteMap revmapfile txt:revmapfile.txt [NC]
RewriteCond %{QUERY_STRING} ^(.+?(type=.+)?)$ [NC]
RewriteRule ^(.*)products/product\.aspx$ http://www.abc.com/$1products/${mapfile:%1}(?%2\?%2) [NC,R=301,L]
RewriteRule ^(.*)products/([^.]*)$ $1products/product.aspx?${revmapfile:$2} [NC,L]

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 21 guests