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: Just a simple rewrite isn’t working for
Author
Message |
gormly
Newbie


Joined: 03 October 2011
Location: United States
Posts: 6
Posted: 03 October 2011 at 10:05am

I just purchased 3.0 and I just want to rewrite:

products.asp?CatID=240&SubCatID=6&item=1234
to
products/240/6/1234/

and

products.asp?product=7907
to
products/7907

I can't seem to do it, everything else I try seems to
work but this simple thing... nada.

Can someone help here?
Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 04 October 2011 at 7:07am

Hello,
Try using the following code:

Code:
RewriteEngine on
RewriteBase /

# 2 rules for 3 parameters
RewriteCond %{QUERY_STRING} ^CatID=(\d+)&SubCatID=(\d+)&item=(\d+)$ [NC]
RewriteRule ^products\.asp$ /products/%1/%2/%3 [NC,R=301,L]
RewriteRule ^products/(\d+)/(\d+)/(\d+)$ /products.asp?CatID=$1&SubCatID=$2&item=$3 [NC,L]

#2 rules for 1 perameter
RewriteCond %{QUERY_STRING} ^product=(\d+)$ [NC]
RewriteRule ^products\.asp$ /products/%1 [NC,R=301,L]
RewriteRule ^products/(\d+)$ /products.asp?product=$1 [NC,L]


Regards
Andrew
Back to Top
 
gormly
Newbie


Joined: 03 October 2011
Location: United States
Posts: 6
Posted: 04 October 2011 at 7:26am

Hi Andrew

thank you, but it still isn't working, perhaps I should
have put that it is not the base folder? does that make a
difference?

the actual URL is
www.mywebsite.com/products/products.asp?
CatID=300&SubCatID=4&sm=sm2_3004

. I wish I understood what was going on here so I could
make adjustments myself, but I seem to be to dense to
"get it" unfortunately.

Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 04 October 2011 at 7:35am

How about this then:

Code:
RewriteEngine on
RewriteBase /

# 2 rules for 3 parameters
#Condition that checks the basic look of the querystring(everything after '?'), it must match thebasic look
RewriteCond %{QUERY_STRING} ^CatID=(\d+)&SubCatID=(\d+)&item=(\d+)$ [NC]
#Rule that uses the condition above, it looks for everything before '?' and redirects it to the nice URL
RewriteRule ^products/products\.asp$ /products/%1/%2/%3 [NC,R=301,L]
#Rule to rewrite the nicelooking URL to load content from the original source
RewriteRule ^products/(\d+)/(\d+)/(\d+)$ /products/products.asp?CatID=$1&SubCatID=$2&item=$3 [NC,L]

#2 rules for 1 perameter
RewriteCond %{QUERY_STRING} ^product=(\d+)$ [NC]
RewriteRule ^products/products\.asp$ /products/%1 [NC,R=301,L]
RewriteRule ^products/(\d+)$ /products/products.asp?product=$1 [NC,L]
Back to Top
 
gormly
Newbie


Joined: 03 October 2011
Location: United States
Posts: 6
Posted: 04 October 2011 at 8:36am

thank you for the help, it's still not working.

I can get it to strip the asp off a page so I know the
component works and it's on the right IIS site.

this is odd. it certainly looks like it should work.

Thanks for the commentary there, I and starting to
understand it now.


The second one kinda works.
On this URL:
http://www.mywebsite.com/products/products.asp?
product=8257

I get
http://www.mywebsite.com/products/8250?product=8250

so there is progress.

:)
Back to Top
 
Guests
Guest


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

Oh, querystring. We can get rid of that:

Code:
RewriteEngine on
RewriteBase /

# 2 rules for 3 parameters

RewriteCond %{QUERY_STRING} ^CatID=(\d+)&SubCatID=(\d+)&item=(\d+)$ [NC]
RewriteRule ^products/products\.asp$ /products/%1/%2/%3? [NC,R=301,L]
RewriteRule ^products/(\d+)/(\d+)/(\d+)$ /products/products.asp?CatID=$1&SubCatID=$2&item=$3 [NC,L]

#2 rules for 1 perameter
RewriteCond %{QUERY_STRING} ^product=(\d+)$ [NC]
RewriteRule ^products/products\.asp$ /products/%1? [NC,R=301,L]
RewriteRule ^products/(\d+)$ /products/products.asp?product=$1 [NC,L]


For those rules that are not working, please, provide the rewrite.log for the testing request.
Logging issues described in FAQ

Regards
Andrew
Back to Top
 
gormly
Newbie


Joined: 03 October 2011
Location: United States
Posts: 6
Posted: 05 October 2011 at 9:55am



This is my code:


Code:
RewriteCond %{QUERY_STRING} ^CatID=(\d+)&SubCatID=
(\d+)&sm=(\d+)$ [NC]
RewriteRule ^products/products\.asp$ /products/%1/%2/%3?
[NC,R=301,L]
RewriteRule ^products/(\d+)/(\d+)/(\d+)$
/products/products.asp?CatID=$1&SubCatID=$2&sm=$3 [NC,L]

#2 rules for 1 perameter
RewriteCond %{QUERY_STRING} ^product=(\d+)$ [NC]
RewriteRule ^products/products\.asp$ /products/%1?
[NC,R=301,L]
RewriteRule ^products/(\d+)$ /products/products.asp?
product=$1 [NC,L]

#Redirect extension requests to avoid duplicate content
RewriteRule ^([^?]+)\.asp$ $1 [NC,R=301,L]

#Internally add extensions to request
RewriteCond %{REQUEST_FILENAME}.asp -f
RewriteRule (.*) $1.asp


This is my log file:

xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx Wed, 05-Oct-2011
10:51:05 GMT [mywebsite.com/sid#2][rid#21452312/initial]
(2) init rewrite engine with requested uri
/products/products.asp?CatID=300&SubCatID=5&sm=sm2_3005
xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx Wed, 05-Oct-2011
10:51:05 GMT [mywebsite.com/sid#2][rid#21452312/initial]
(1) Htaccess process request C:\Program
Files\Helicon\ISAPI_Rewrite3\httpd.conf
xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx Wed, 05-Oct-2011
10:51:05 GMT [mywebsite.com/sid#2][rid#21452312/initial]
(1) Htaccess process request
c:\websites\mywebsite.com\.htaccess
xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx Wed, 05-Oct-2011
10:51:05 GMT [mywebsite.com/sid#2][rid#21452312/initial]
(3) applying pattern '^products/products\.asp$' to uri
'products/products.asp'
xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx Wed, 05-Oct-2011
10:51:05 GMT [mywebsite.com/sid#2][rid#21452312/initial]
(4) RewriteCond: input='CatID=300&SubCatID=5&sm=sm2_3005'
pattern='^CatID=(\d+)&SubCatID=(\d+)&sm=(\d+)$' => not-
matched



Edited by gormly - 05 October 2011 at 9:56am
Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 06 October 2011 at 5:19am

The problem the pattern didn't match is - "sm=sm2_3005"
I used (\d+) to indicate NUMERIC value(I concluded from example that it's always digits), while you have integer.

Try replacing the existing condition with:

RewriteCond %{QUERY_STRING} ^CatID=(\d+)&SubCatID=(\d+)&sm=([^&]+)$

Regards
Andrew
Back to Top
 
gormly
Newbie


Joined: 03 October 2011
Location: United States
Posts: 6
Posted: 06 October 2011 at 7:45am

So it should be:

Code:

RewriteCond %{QUERY_STRING} ^CatID=(\d+)&SubCatID=
(\d+)&sm=([^&]+)$ [NC]
RewriteRule ^products/products\.asp$ /products/%1/%2/%3?
[NC,R=301,L]
RewriteRule ^products/(\d+)/(\d+)/([^&]+)$
/products/products.asp?CatID=$1&SubCatID=$2&sm=$3 [NC,L]


Is this correct? I changed the type in both places the
RewriteCond and RewriteRule


I now get loops or not founds, so while I am learning
this a bit :), it still seems to give me trouble.
This is actually the only thing I purchased this for so
once I have this right, I am done.

Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 07 October 2011 at 3:28am


I would rather say:

Code:
RewriteCond %{QUERY_STRING} ^CatID=(\d+)&SubCatID=(\d+)&sm=([^&]+)$ [NC]
RewriteRule ^products/products\.asp$ /products/%1/%2/%3? [NC,R=301,L]
RewriteRule ^products/(\d+)/(\d+)/([^/]+)/?$ /products/products.asp?CatID=$1&SubCatID=$2&sm=$3 [NC,L]


But this won't help in looping. Do you have any other rules in your config file, that may participate in process?
Would you do thew log again?

Regards
Andrew
Back to Top
 
gormly
Newbie


Joined: 03 October 2011
Location: United States
Posts: 6
Posted: 10 October 2011 at 8:26am

that last one works great!

Unfortunately all my graphics no longer load..
LOL, if it's not one thing it's another.

that's all I have running, nothing else at this point.
Just weird, when I apply this rule, no graphical elements
show up, all pages and css are screwed.


Edited by gormly - 10 October 2011 at 8:27am
Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 11 October 2011 at 3:41am

That's okay. Well, it is not, but it is fixable.

Your links are also being affected by ISAPI_Rewrite. So for that you need all your links to be fixed .css and graphic to me root-relative or absolute format.

Regards
Andrew
Back to Top
 

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

Printable version Printable version