This forum has been moved here:
Helicon Tech Community Forum

ISAPI_Rewrite 3.0 (Forum Locked Forum Locked)
 Helicon Tech : ISAPI_Rewrite 3.0
Subject Topic: Re writing and product fitering
Author
Message |
AndyM
Newbie


Joined: 11 July 2011
Posts: 12
Posted: 15 September 2011 at 9:16am

HI

I've got the following code which works well for if someone searches for a brand then filters for the second set of records, I have the facility to re order the results which just uses a simple form to post the value to filter on, the only problem is when i have the re writes enabled it doesnt work, im guessing i need to add something either before or after the offset but i'm not sure what.

any help appreciated

RewriteMap brand txt:brand.txt
RewriteMap revbrand txt:revbrand.txt

RewriteCond %{QUERY_STRING} Brand=(\d+)&offset=(\d+)$ [NC]
RewriteCond ${brand:%1|NOT_FOUND} !NOT_FOUND
RewriteRule ^products\.asp$ brands/%2/${brand:%1}.asp? [NC,R=301,L]
RewriteRule ^brands/(\d+)/([^?/]+)\.asp /products.asp?Brand=${revbrand:$2}&offset=$1 [NC,L]

RewriteCond %{QUERY_STRING} Brand=(.*)$ [NC]
RewriteCond ${brand:%1|NOT_FOUND} !NOT_FOUND
RewriteRule products\.asp$ brands/${brand:%1}.asp? [NC,R=301,L]
RewriteRule ^brands/([^?/]+)\.asp /products.asp?Brand=${revbrand:$1}

Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 19 September 2011 at 4:30am

Hello,

This is a common issue called "postback". The solution, that has proved itself is a condition that does not work with POST events.
Try using the following code for your rules:

Code:
RewriteCond %{REQUEST_METHOD} !^POST$ [NC]


Regards
Andrew
Back to Top
 
AndyM
Newbie


Joined: 11 July 2011
Posts: 12
Posted: 19 September 2011 at 4:55am

Excellent thanks!!! will give it a go now!
Back to Top
 
AndyM
Newbie


Joined: 11 July 2011
Posts: 12
Posted: 19 September 2011 at 9:23am

I've put the code in and it now orders them correctly but after the post it doesn't re write the url

RewriteMap brand txt:brand.txt
RewriteMap revbrand txt:revbrand.txt

#RewriteCond %{REQUEST_METHOD} !^POST$ [NC]
RewriteCond %{QUERY_STRING} Brand=(\d+)&offset=(\d+)$ [NC]
RewriteCond ${brand:%1|NOT_FOUND} !NOT_FOUND
RewriteRule ^products\.asp$ brands/%2/${brand:%1}.asp? [NC,R=301,L]
RewriteRule ^brands/(\d+)/([^?/]+)\.asp /products.asp?Brand=${revbrand:$2}&offset=$1 [NC,L]

RewriteCond %{REQUEST_METHOD} !^POST$ [NC]
RewriteCond %{QUERY_STRING} Brand=(.*)$ [NC]
RewriteCond ${brand:%1|NOT_FOUND} !NOT_FOUND
RewriteRule products\.asp$ brands/${brand:%1}.asp? [NC,R=301,L]
RewriteRule ^brands/([^?/]+)\.asp /products.asp?Brand=${revbrand:$1}

Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 20 September 2011 at 8:16pm

What do you mean by "after the post it doesn't rewrite the url"?
Which request follows the post?

Regards
Andrew
Back to Top
 
AndyM
Newbie


Joined: 11 July 2011
Posts: 12
Posted: 21 September 2011 at 9:05am

HI

Sorry, i will try to explain it better

If someone clicks a link or visits the brand page it re writes it to /brands/brandname.asp

if they then select say order by price from a drop down in a form, click submit, the filter works fine and the results are displayed but instead of displaying brands/brandname.asp
it now displays the original url of products.asp?Brand=1

does that make more sense?

cheers
Andy



Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 22 September 2011 at 4:56am

Please, provide Rewrite.log for the testing request like this.
Logging issue described in FAQ

Regards
Andrew
Back to Top
 
AndyM
Newbie


Joined: 11 July 2011
Posts: 12
Posted: 22 September 2011 at 6:58am

Sorry here's the contents of the files

error.log
[9/22/2011 12:23:27] Map file \httpdocs\showcasecategory.txt - Loaded successfully
[9/22/2011 12:23:27] Map file \httpdocs\revshowcasecategory.txt - Loaded successfully
[9/22/2011 12:23:27] Map file \httpdocs\showcaserange.txt - Loaded successfully
[9/22/2011 12:23:27] Map file \httpdocs\revshowcaserange.txt - Loaded successfully
[9/22/2011 12:23:27] Map file \httpdocs\showcaseproducts.txt - Loaded successfully
[9/22/2011 12:23:27] Map file \httpdocs\revshowcaseproducts.txt - Loaded successfully
[9/22/2011 12:23:27] Map file \httpdocs\category.txt - Loaded successfully
[9/22/2011 12:23:27] Map file \httpdocs\revcategory.txt - Loaded successfully
[9/22/2011 12:23:27] Map file \httpdocs\brand.txt - Loaded successfully
[9/22/2011 12:23:27] Map file \httpdocs\revbrand.txt - Loaded successfully
[9/22/2011 12:23:27] Map file \httpdocs\room.txt - Loaded successfully
[9/22/2011 12:23:27] Map file \httpdocs\revroom.txt - Loaded successfully
[9/22/2011 12:23:27] Map file \httpdocs\size.txt - Loaded successfully
[9/22/2011 12:23:27] Map file \httpdocs\revsize.txt - Loaded successfully
[9/22/2011 12:23:27] Map file \httpdocs\style.txt - Loaded successfully
[9/22/2011 12:23:27] Map file \httpdocs\revstyle.txt - Loaded successfully
[9/22/2011 12:23:27] Map file \httpdocs\colour.txt - Loaded successfully
[9/22/2011 12:23:27] Map file \httpdocs\revcolour.txt - Loaded successfully
[9/22/2011 12:23:27] Map file \httpdocs\products.txt - Loaded successfully
[9/22/2011 12:23:27] Map file \httpdocs\revproducts.txt - Loaded successfully
[9/22/2011 12:23:27] Map file \httpdocs\special.txt - Loaded successfully
[9/22/2011 12:23:27] Map file \httpdocs\revspecial.txt - Loaded successfully
[9/22/2011 12:23:27] Map file \httpdocs\bestsellers.txt - Loaded successfully
[9/22/2011 12:23:27] Map file \httpdocs\revbestsellers.txt - Loaded successfully
[9/22/2011 12:23:27] \httpdocs\.htaccess - Loaded successfully

and the rewrite.log is here.
Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 23 September 2011 at 5:43am

Unfortunately, Didn't fin'd any entry regarding request to /brand/XXXXXX.asp.
I'm just thinking you may forgotten to put [NC,L] after the RewriteRule ^brands/([^?/]+)\.asp /products.asp?Brand=${revbrand:$1}, so it keeps processing the resulted
request and ends up redirecting.

Regards
Andrew
Back to Top
 
AndyM
Newbie


Joined: 11 July 2011
Posts: 12
Posted: 23 September 2011 at 8:41am

I've added that on the end and still no different, it's the same with the others, if i filter by category, then do the re order it shows as products.asp?Cat=1 etc
Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 27 September 2011 at 8:50am

Have you followed the my advise from the helpdesk, to add condition?

Regards
Andrew
Back to Top
 
AndyM
Newbie


Joined: 11 July 2011
Posts: 12
Posted: 27 September 2011 at 8:55am

Sorry not had chance, I got bogged down with some other bits, I will have a go today and let you know.

cheers

Back to Top
 

Sorry, you can NOT post a reply.
This forum has been locked by a forum administrator.

Printable version Printable version