Order of processing IIS7 ISAPI_Rewrite 3.0

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 92
Joined: 01 Dec 2012, 14:22

Order of processing IIS7 ISAPI_Rewrite 3.0

27 Aug 2013, 08:01

Hi,

I have a weird problem with what looks like a simple rule.

The web site is served from a folder called "website"

There is a virtual directory called "amot-search" pointed to the same root folder, and it contains a default.asp file.

What I'm trying to achieve is to create a "default document" for this VDir, using a rewrite rule (as IIS7 seemingly won't allow you to have a default document with a query string, unlike IIS6).

httpd.conf contains a <VirtualHost> directive enabling the site.

#Amot
<VirtualHost www.armymuseums.co.uk>

The .htaccess file for the site contains:

RewriteRule ^amot-search/$ amot-search/default.asp?Category=Amot&Service=Museum-Search [LC,NS,L]

Calling this as www.armymuseums.co.uk/amot-search/ gets a 404.

However, there's nothing in the rewrite log - so it looks as though this process hasn't reached ISAPI-Rewrite.

If I call the target URL explicitly:

www.armymuseums.co.uk/amot-search/defau ... eum-Search

then:

1) The page renders as desired and
2) There is a log entry in the rewrite log processing the request (but not rewriting it as no rules are in force).

If I change the rewrite rule to:

RewriteRule ^amot-search$ amot-search/default.asp?Category=Amot&Service=Museum-Search [LC,NS,L]

- and submit the URL *without* the trailing slash,
www.armymuseums.co.uk/amot-search

- then it works.

So, to my eye, this looks like a permissions issue, which is why I'm asking:

1) What is the order in which things are processed when a URL is submitted? It looks like the 404 is generated without the filter being activated, because it causes no logging?
2) If it *is* permissions, what permissions am I likely to need to make this work properly?

This is particularly puzzling, as I have another site on the same machine that works just fine with this approach- I'm clearly missing something, but I can't figure out what.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Order of processing IIS7 ISAPI_Rewrite 3.0

27 Aug 2013, 11:24

Hello,

First, ISAPI_Rewrite treats virtual folders just like any other folder.

1) all our secrets are described here:
- http://www.helicontech.com/articles/exp ... te-part-i/
- http://www.helicontech.com/articles/exp ... te-part-2/
2) i'm not sure it's permissions. If it is, than in error.log you'd have a corresponding entry.

Could there be another rule that deals with trailing slashes?
You can also try:

Code: Select all
RewriteRule ^amot-search/?$ amot-search/default.asp?Category=Amot&Service=Museum-Search [LC,NS,L]

which makes a slash at the end optional.

Regards
Andrew

User avatar
Posts: 92
Joined: 01 Dec 2012, 14:22

Re: Order of processing IIS7 ISAPI_Rewrite 3.0

28 Aug 2013, 11:52

That change makes no difference.

It still works without the slash, but not with it (which is particularly problematic with some browsers, which seem to want to add the / for you).

The thing is, we have logging switched on, at debug level.

When you submit it without the slash, the log contains all the processing. When you submit it *without* the slash, there is *nothing* in the log- there's no sign of that URL being submitted to ISAPI_rewrite for consideration. Which is why I'm wondering about permissions: could IIS be deciding that it's not going to permit the directory to be listed *before* applying ISAPI filters?

User avatar
Posts: 92
Joined: 01 Dec 2012, 14:22

Re: Order of processing IIS7 ISAPI_Rewrite 3.0

28 Aug 2013, 12:35

Hmmm.

Now I'm seeing:

16:26:31 GMT [www.armymuseums.co.uk/sid#16][rid#18883560/initial] (2) init rewrite engine with requested uri /amot-search/
16:26:31 GMT [www.armymuseums.co.uk/sid#16][rid#18883560/initial] (1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
16:26:31 GMT [www.armymuseums.co.uk/sid#16][rid#18883560/initial] (1) Htaccess process request
16:26:31 GMT [www.armymuseums.co.uk/sid#16][rid#18883560/initial] (1) Htaccess process request e:\web sites\amot\web site\.htaccess
16:26:31 GMT [www.armymuseums.co.uk/sid#16][rid#18883560/initial] (3) applying pattern '^amot-admin/?$' to uri ''
16:26:31 GMT [www.armymuseums.co.uk/sid#16][rid#18883560/initial] (3) applying pattern '^amot-search/?$' to uri ''
16:26:31 GMT [www.armymuseums.co.uk/sid#16][rid#18883560/initial] (3) applying pattern '^amot-user/?$' to uri ''

Which I wasn't seeing before: but it's not seemingly triggering?

I'm assuming that the logging is written out in blocks- it's sometimes quite a delay from submitting a URL to seeing anything in the log?

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Order of processing IIS7 ISAPI_Rewrite 3.0

28 Aug 2013, 12:59

That's strange!!! Very!

first it says
Code: Select all
(2) init rewrite engine with requested uri /amot-search/

then
Code: Select all
(3) applying pattern '^amot-admin/?$' to uri ''


It's the same request, but further in the processing it looks like the request is blank(as if you're requesting the root). Are you sure there's nothing else that takes place here?
Give me more info... IIS version, CMS?, PLESK?, ColdFusion?, RewriteBase directive?

This shoudln't be happening.

Regards
ANdrew

User avatar
Posts: 92
Joined: 01 Dec 2012, 14:22

Re: Order of processing IIS7 ISAPI_Rewrite 3.0

28 Aug 2013, 13:16

I'm seeing:

init rewrite engine with requested uri /amot-search
Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
Htaccess process request
Htaccess process request e:\web sites\amot\web site\.htaccess
applying pattern '^amot-admin/?$' to uri 'amot-search'
applying pattern '^amot-search/?$' to uri 'amot-search'
Rewrite URL to >> /amot-search/default.asp?Category=Amot&Service=Museum-Search
rewrite 'amot-search' -> '/amot-search/default.asp?Category=Amot&Service=Museum-Search'
internal redirect with /amot-search/default.asp?Category=Amot&Service=Museum-Search [INTERNAL REDIRECT]

- which is fine.

And then:

init rewrite engine with requested uri /amot-search/
Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
Htaccess process request
Htaccess process request e:\web sites\amot\web site\.htaccess
applying pattern '^amot-admin/?$' to uri ''
applying pattern '^amot-search/?$' to uri ''
applying pattern '^amot-user/?$' to uri ''

So, as you say, it's somehow misapplying the uri.

IIS version is 7
No CMS, Plesk, ColdFusion etc etc- it's a dedicated server, not a slice of shared hosting (it *is* shared hosting, but my client is the server owner).
The platform is called CoolICE, and it uses classic ASP, hence all the "default.asp" stuff.

*AH*!

I think I found it: there's no "RewriteBase" directive.

Let me add it in.....

Aha!

Adding "RewriteBase /" makes it all spring into life!

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Order of processing IIS7 ISAPI_Rewrite 3.0

28 Aug 2013, 13:43

Wait! it fixed it? I'm suprised....

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 24 guests