Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
ISAPI_Rewrite 2.x
 Helicon Tech : ISAPI_Rewrite 2.x
Subject Topic: Issue rewriting rules Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
jchandler
Newbie
Newbie


Joined: 12 June 2010
Online Status: Offline
Posts: 1
Posted: 12 June 2010 at 5:10pm | IP Logged Quote jchandler

I'm attempting to rewrite all the URL's of my site and have it almost there
with a few exceptions.

This is what I'm trying to do:

1. Remove ".asp" extension from url - working except for root domain
(404 error)

2. rewrite query strings for two different pages. The issue is there will be
a max of 3 addl params but not always all three.

I need these (same page) to all work without needing three rules:
domain.com/page/string1 -> domain.com/page.asp?q=string1

domain.com/page/string1-string2 -> domain.com/page.asp?
q=string1&w=string2

domain.com/page/string1-string2-string3 -> domain.com/page.asp?
q=string1&w=string2&y=string3

The above works only if I leave the trailing "-" after each string.
Code:
#url rewrite site-wide
#shop pages
RewriteRule /shop/([^/]+)-([^/]*) /shop_all.asp\?CAT=$1&SUBCAT=$2
[I,L]
#product pages
RewriteRule /products/([^/]+)-([^/]*)-([^/]*) /product.asp\?
itemno=$1&CAT=$2&SUBCAT=$3 [I,L]

#remaining pages
RewriteRule ^([^\.\?]+)/?(\?.*)?$ /$1.asp$2 [L]


Any help would be great, thanks!
Back to Top View jchandler's Profile Search for other posts by jchandler
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10489
Posted: 14 June 2010 at 4:59am | IP Logged Quote Anton

Please try to fix your config like this:

#url rewrite site-wide
#shop pages
RewriteRule /shop/([^/]+)(?:-([^/]+))? /shop_all.asp\?CAT=$1(?2&SUBCAT=$2) [I,L]

#product pages
RewriteRule /products/([^/]+)(?:-([^/]+)(?:-([^/]+))?)? /product.asp\?itemno=$1(?2&CAT=$2)(?3&SUBCAT=$3) [I,L]

#remaining pages
RewriteRule (?!(?:images|css|js|script|etc))([^.?]+[^.?/])/?(\?.+)?$ $1.asp(?2$2) [I,L]

__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum