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: Regex problem
Author
Message |
davidlarder
Newbie


Joined: 22 September 2011
Location: United Kingdom
Posts: 6
Posted: 22 September 2011 at 8:39am

Hi

I'm very new to ISAPI Reqrite and also Regex, so please excuse my ignorance!

I have the following rule:

RewriteRule    /data-cleansing/([A-Za-z0-9-]+)/ /pages/common/page.aspx?name=$1

Which works fine for the following: "/data-cleansing/this-is-a-test"

this will end up as: "/pages/common/page.aspx?name=this-is-a-test"

However if there's a dot (.) in the URL this isn't being matched.

What do I need to change in the rule so that "/data-cleansing/test.com" is matched?

Thanks in advance!

David
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 23 September 2011 at 2:32am

Try fixing the rule like this:

RewriteRule /data-cleansing/([^/]+)/ /pages/common/page.aspx?name=$1

__________________
Regards,
Anton
Back to Top
 
davidlarder
Newbie


Joined: 22 September 2011
Location: United Kingdom
Posts: 6
Posted: 23 September 2011 at 3:22am

Hi Anton

Thanks for the reply.

It only seems to work if I also put a "/" at the end of
the URL.

i.e. "/data-cleansing/test.com" doesn't work, but "/data-
cleansing/test.com/" does.

I tried removing the slash at the end of the rule so it
reads "/data-cleansing/([^/]+)" which kind of worked, but
this means that "/data-cleansing/" is being matched too.

This is a problem, because I another rule:

/data-cleansing /pages/common/page.aspx?name=datacleaning

which isn't being caught now.

Any ideas?
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 23 September 2011 at 3:50am

Ok, let's try it the following way:

RewriteBase /
RewriteRule ^data-cleansing$ /pages/common/page.aspx?name=datacleaning [NC,L]
RewriteRule ^data-cleansing/([^/]+)/?$ /pages/common/page.aspx?name=$1 [NC,L]

__________________
Regards,
Anton
Back to Top
 
davidlarder
Newbie


Joined: 22 September 2011
Location: United Kingdom
Posts: 6
Posted: 23 September 2011 at 4:05am

No, that didn't work.

Only "/data-cleansing/with.dot" is being caught, "data-
cleansing/test" isn't working.

Also, "/data-cleansing" is not being sent to
"/pages/common/page.aspx?name=datacleaning"

Don't waste too much time trying to figure it out Anton -
if I avoid using dots in my URLs then I can use my old
rules which seem to work.

Thanks for the replies though!

David
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 23 September 2011 at 4:19am

It's my job to try figure it out :)
But it sounds totally weird.
Just for clarification, are you using ISAPI_Rewrite v3?
If yes, please enable logging in httpd.conf by putting

RewriteLogLevel 9

Then make some failing request and show rewrite.log records to me.

__________________
Regards,
Anton
Back to Top
 
davidlarder
Newbie


Joined: 22 September 2011
Location: United Kingdom
Posts: 6
Posted: 23 September 2011 at 4:35am

Yes, I'm using v3.

OK, with the last rules you suggested:

Trying to reach "/data-cleansing/test" I get the
following:

195.59.101.254 195.59.101.254 Fri, 23-Sep-2011 10:27:51
GMT [www.improvemydata.com/sid#752519]
[rid#20196176/initial] (2) init rewrite engine with
requested uri /data-
cleansing/test/eurl.axd/7298f58df06b814c96dbb2ccf8c69a14
195.59.101.254 195.59.101.254 Fri, 23-Sep-2011 10:27:51
GMT [www.improvemydata.com/sid#752519]
[rid#20196176/initial] (1) Htaccess process request
C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
195.59.101.254 195.59.101.254 Fri, 23-Sep-2011 10:27:51
GMT [www.improvemydata.com/sid#752519]
[rid#20196176/initial] (3) applying pattern
'/pages/common/datacleaning.aspx' to uri 'data-
cleansing/test/eurl.axd/7298f58df06b814c96dbb2ccf8c69a14'
195.59.101.254 195.59.101.254 Fri, 23-Sep-2011 10:27:51
GMT [www.improvemydata.com/sid#752519]
[rid#20196176/initial] (3) applying pattern
'/pages/common/page.aspx\?name=address-management' to uri
'data-
cleansing/test/eurl.axd/7298f58df06b814c96dbb2ccf8c69a14'
195.59.101.254 195.59.101.254 Fri, 23-Sep-2011 10:27:51
GMT [www.improvemydata.com/sid#752519]
[rid#20196176/initial] (3) applying pattern
'/pages/common/page.aspx\?name=mps-tps' to uri 'data-
cleansing/test/eurl.axd/7298f58df06b814c96dbb2ccf8c69a14'
195.59.101.254 195.59.101.254 Fri, 23-Sep-2011 10:27:51
GMT [www.improvemydata.com/sid#752519]
[rid#20196176/initial] (3) applying pattern
'/pages/common/page.aspx\?name=credit-pre-screening' to
uri 'data-
cleansing/test/eurl.axd/7298f58df06b814c96dbb2ccf8c69a14'
195.59.101.254 195.59.101.254 Fri, 23-Sep-2011 10:27:51
GMT [www.improvemydata.com/sid#752519]
[rid#20196176/initial] (3) applying pattern
'/pages/common/page.aspx\?name=other-data-cleansing-
services' to uri 'data-
cleansing/test/eurl.axd/7298f58df06b814c96dbb2ccf8c69a14'
195.59.101.254 195.59.101.254 Fri, 23-Sep-2011 10:27:51
GMT [www.improvemydata.com/sid#752519]
[rid#20196176/initial] (3) applying pattern
'/pages/common/page.aspx\?name=data-enhancement' to uri
'data-
cleansing/test/eurl.axd/7298f58df06b814c96dbb2ccf8c69a14'
195.59.101.254 195.59.101.254 Fri, 23-Sep-2011 10:27:51
GMT [www.improvemydata.com/sid#752519]
[rid#20196176/initial] (3) applying pattern
'/pages/common/page.aspx\?name=mortality-screening' to
uri 'data-
cleansing/test/eurl.axd/7298f58df06b814c96dbb2ccf8c69a14'
195.59.101.254 195.59.101.254 Fri, 23-Sep-2011 10:27:51
GMT [www.improvemydata.com/sid#752519]
[rid#20196176/initial] (3) applying pattern
'/pages/common/page.aspx\?name=de-duplication' to uri
'data-
cleansing/test/eurl.axd/7298f58df06b814c96dbb2ccf8c69a14'
195.59.101.254 195.59.101.254 Fri, 23-Sep-2011 10:27:51
GMT [www.improvemydata.com/sid#752519]
[rid#20196176/initial] (3) applying pattern
'/pages/common/page.aspx\?name=email-appending' to uri
'data-
cleansing/test/eurl.axd/7298f58df06b814c96dbb2ccf8c69a14'
195.59.101.254 195.59.101.254 Fri, 23-Sep-2011 10:27:51
GMT [www.improvemydata.com/sid#752519]
[rid#20196176/initial] (3) applying pattern
'/pages/common/page.aspx\?name=goneaway-suppression' to
uri 'data-
cleansing/test/eurl.axd/7298f58df06b814c96dbb2ccf8c69a14'
195.59.101.254 195.59.101.254 Fri, 23-Sep-2011 10:27:51
GMT [www.improvemydata.com/sid#752519]
[rid#20196176/initial] (3) applying pattern
'/pages/common/page.aspx\?name=residency-verification' to
uri 'data-
cleansing/test/eurl.axd/7298f58df06b814c96dbb2ccf8c69a14'
195.59.101.254 195.59.101.254 Fri, 23-Sep-2011 10:27:51
GMT [www.improvemydata.com/sid#752519]
[rid#20196176/initial] (3) applying pattern
'/pages/common/page.aspx\?name=tele-append' to uri 'data-
cleansing/test/eurl.axd/7298f58df06b814c96dbb2ccf8c69a14'
195.59.101.254 195.59.101.254 Fri, 23-Sep-2011 10:27:51
GMT [www.improvemydata.com/sid#752519]
[rid#20196176/initial] (3) applying pattern
'/pages/common/page.aspx\?name=data-enhancement' to uri
'data-
cleansing/test/eurl.axd/7298f58df06b814c96dbb2ccf8c69a14'
195.59.101.254 195.59.101.254 Fri, 23-Sep-2011 10:27:51
GMT [www.improvemydata.com/sid#752519]
[rid#20196176/initial] (3) applying pattern
'/datasources/([A-Za-z0-9-]+)/' to uri 'data-
cleansing/test/eurl.axd/7298f58df06b814c96dbb2ccf8c69a14'
195.59.101.254 195.59.101.254 Fri, 23-Sep-2011 10:27:51
GMT [www.improvemydata.com/sid#752519]
[rid#20196176/initial] (3) applying pattern
'/datasources' to uri 'data-
cleansing/test/eurl.axd/7298f58df06b814c96dbb2ccf8c69a14'
195.59.101.254 195.59.101.254 Fri, 23-Sep-2011 10:27:51
GMT [www.improvemydata.com/sid#752519]
[rid#20196176/initial] (3) applying pattern
'/datasources/([A-Za-z0-9-]+)/' to uri 'data-
cleansing/test/eurl.axd/7298f58df06b814c96dbb2ccf8c69a14'
195.59.101.254 195.59.101.254 Fri, 23-Sep-2011 10:27:51
GMT [www.improvemydata.com/sid#752519]
[rid#20196176/initial] (3) applying pattern '/data-
sources/([A-Za-z0-9-]+)/' to uri 'data-
cleansing/test/eurl.axd/7298f58df06b814c96dbb2ccf8c69a14'
195.59.101.254 195.59.101.254 Fri, 23-Sep-2011 10:27:51
GMT [www.improvemydata.com/sid#752519]
[rid#20196176/initial] (3) applying pattern '/data-
sources' to uri 'data-
cleansing/test/eurl.axd/7298f58df06b814c96dbb2ccf8c69a14'
195.59.101.254 195.59.101.254 Fri, 23-Sep-2011 10:27:51
GMT [www.improvemydata.com/sid#752519]
[rid#20196176/initial] (3) applying pattern '^data-
cleansing$' to uri 'data-
cleansing/test/eurl.axd/7298f58df06b814c96dbb2ccf8c69a14'
195.59.101.254 195.59.101.254 Fri, 23-Sep-2011 10:27:51
GMT [www.improvemydata.com/sid#752519]
[rid#20196176/initial] (3) applying pattern '^data-
cleansing/([^/]+)/?$' to uri 'data-
cleansing/test/eurl.axd/7298f58df06b814c96dbb2ccf8c69a14'
195.59.101.254 195.59.101.254 Fri, 23-Sep-2011 10:27:51
GMT [www.improvemydata.com/sid#752519]
[rid#20196176/initial] (3) applying pattern '/data-
cleansing' to uri 'data-
cleansing/test/eurl.axd/7298f58df06b814c96dbb2ccf8c69a14'
195.59.101.254 195.59.101.254 Fri, 23-Sep-2011 10:27:51
GMT [www.improvemydata.com/sid#752519]
[rid#20196176/initial] (3) applying pattern '/news/' to
uri 'data-
cleansing/test/eurl.axd/7298f58df06b814c96dbb2ccf8c69a14'
195.59.101.254 195.59.101.254 Fri, 23-Sep-2011 10:27:51
GMT [www.improvemydata.com/sid#752519]
[rid#20196176/initial] (3) applying pattern '/ourclients'
to uri 'data-
cleansing/test/eurl.axd/7298f58df06b814c96dbb2ccf8c69a14'
195.59.101.254 195.59.101.254 Fri, 23-Sep-2011 10:27:51
GMT [www.improvemydata.com/sid#752519]
[rid#20196176/initial] (3) applying pattern '/our-
clients/' to uri 'data-
cleansing/test/eurl.axd/7298f58df06b814c96dbb2ccf8c69a14'
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 23 September 2011 at 9:33am

Ok, the request appears to be /data-cleansing/test/eurl.axd/7298f58df06b814c96dbb2ccf8c69a14 which means the rule I've composed won't suit
because of another slash I was not expecting.

Let's try it the following way:

RewriteBase /
RewriteRule ^data-cleansing$ /pages/common/page.aspx?name=datacleaning [NC,L]
RewriteRule ^data-cleansing/([^/]+?)(?:/.*)?$ /pages/common/page.aspx?name=$1 [NC,L]

__________________
Regards,
Anton
Back to Top
 
davidlarder
Newbie


Joined: 22 September 2011
Location: United Kingdom
Posts: 6
Posted: 23 September 2011 at 9:46am

I'm not sure why the request is showing as "/data-
cleansing/test/eurl.axd/7298f58df06b814c96dbb2ccf8c69a14"

In my browser it's just "/data-cleansing/test"

I think this is probably the cause of my problems!

Any idea what could be adding this extra bit onto the URL?
Back to Top
 
davidlarder
Newbie


Joined: 22 September 2011
Location: United Kingdom
Posts: 6
Posted: 23 September 2011 at 10:20am

Found this - ExtensionlessUrls associated with ASP.NET 4 which may
explain it.

I've turned the feature off via the registry and it looks like the following works:

RewriteRule /data-cleansing/([^/]+) /pages/common/page.aspx?name=$1
RewriteRule /data-cleansing /pages/common/page.aspx?name=datacleaning



Thanks very much!

Edited by davidlarder - 23 September 2011 at 10:21am
Back to Top
 

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

Printable version Printable version