Rewrite rule with subdomain. Simple, but ineffective.

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 4
Joined: 31 Jul 2012, 16:18

Rewrite rule with subdomain. Simple, but ineffective.

31 Jul 2012, 17:09

IIS6, Isapi RW 3.x

Virtual host with FTP access only

I have a subdomain I'm using for developing a client website:
http://rk.commadelimited.com/

This subdomain points to
http://commadelimited.com/clients/richkalonick/

I want all requests to my data layer to be rewritten. The structure of the requests look like this (with the red part changing based on user selection):

http://rk.commadelimited.com/data/home/md/

All of the requests should be routed to this file:

http://rk.commadelimited.com/data/photos.json

I've verified that the JSON file can be accessed, but none of the rules I've tried make any difference. Here's some of the things I've tried in this file http://commadelimited.com/clients/richkalonick/httpd.ini

-----------
RewriteEngine on
RewriteRule (.*)/data/(\w+)/(\w{2})/ $1/data/photos.json
-----------
RewriteEngine on
RewriteBase /
RewriteRule data/(\w+)/(\w{2})/ data/photos.json
-----------
RewriteEngine on
RewriteRule data/(\w+)/(\w\w)/ data/photos.json
-----------
RewriteEngine on
RewriteRule data/(\w+)/(\w\w)/ http://www.google.com
-----------
RewriteEngine on
RewriteBase /
RewriteRule ^data/home/md/ ^data/photos.json
-----------

As you can see I've even tried hard-coding the incoming file request straight up with no success.

Can anyone please point me in the right direction? I know that Isapi works on this host, with my account as I have another site using it successfully. In fact, here's the httpd.ini file from that website:

[ISAPI_Rewrite]
RewriteRule (.*)/category/([-a-zA-Z0-9\.]+)/ $1/index.cfm?verb=category&term=$2
RewriteRule (.*)/read/([0-9]+)/([0-9]+)/([0-9]+)/(.*) $1/index.cfm?verb=read&date=$2-$3-$4&title=$5
RewriteRule (.*)/page/([0-9-]+)/ $1/index.cfm?verb=page&num=$2
RewriteRule (.*)/rss/(.*)? $1/rss.cfm?feed=$2
RewriteRule (.*)/unsubscribe/(.*)? $1/unsubscribe.cfm?details=$2
RewriteRule (.*)/contact/ $1/index.cfm?contactform=true

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

Re: Rewrite rule with subdomain. Simple, but ineffective.

01 Aug 2012, 06:39

Hello,

You've done a good job describing the issue, so I'll try to make easy for you to find the source of the issue:

Code: Select all
RewriteEngine on
RewriteBase /

RewriteRule ^data/([^/]+)/([^/]+)/?$ data/photos.json [NC,L]


But for some reason you're speaking about httpd.ini, not httpd.conf or .htaccess. While httpd.ini is an ISAPI_Rewrite 2 config file, which is no longer supported by ISAPI_Rewrite 3. It's described here.

I'd also suggest starting with FAQ. It has a testing rule and the way to enable logging. This would be the best to start with.

Regards
Andrew

User avatar
Posts: 4
Joined: 31 Jul 2012, 16:18

Re: Rewrite rule with subdomain. Simple, but ineffective.

01 Aug 2012, 14:16

Andrew...

The Isapi rules at the end of my original post are contained in an httpd.ini file on http://andyMatthews.net, and they work great there. My host confirmed with me yesterday that they're using Isapi 3.0. Since it's on the same host and account I assumed that I could simply use the same approach.

I placed the rules you described into my httpd.ini file and uploaded them into the subdirectory. I tested against the following URL:
http://rk.commadelimited.com/data/home/sm/

I also placed the rules you described into an httpd.conf file and uploaded them into the subdirectory. I tested against the following URL:
http://rk.commadelimited.com/data/home/sm/

Finally I placed the rules you described into an .htaccess file and uploaded them into the subdirectory. I tested against the following URL:
http://rk.commadelimited.com/data/home/sm/

None of the three options worked.

I want to mention again (if it matters) that I don't have access to configure the server directly. I can only use configuration files. Also, I'm working within the context of a subdomain (again, if it matters).

Is there anything that I can ask my host that would help verify that Isapi is functioning properly within the scope of this domain?

Also, I tried using the following rule:

RewriteRule .? - [F]

In all three file types (httpd.ini, httpd.conf, and .htaccess) as suggested in the link you posted and none of them responded with a 403.

User avatar
Posts: 4
Joined: 31 Jul 2012, 16:18

Re: Rewrite rule with subdomain. Simple, but ineffective.

01 Aug 2012, 22:35

Update. My host was apparently mistaken about the version. I was previously on Isapi 2.x. They upgraded my account to 3.x and I ran through the "does it work" test again.

I put the following rewrite rule in httpd.ini, httpd.conf, and .htaccess in the subdirectory:
RewriteRule .? - [F]

But I still received a page not found error instead of a 403 forbidden.

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

Re: Rewrite rule with subdomain. Simple, but ineffective.

02 Aug 2012, 04:45

This could be a result of insufficient permissions.

Usually the hosting companies are very tough and they cut permissions. Please, show this documentation to your provider.
Basically what you need is to provide read permissions for User that runs your site's pool and/or for IIS_WPG group of users.

Regards
Andrew

User avatar
Posts: 4
Joined: 31 Jul 2012, 16:18

Re: Rewrite rule with subdomain. Simple, but ineffective.

02 Aug 2012, 15:41

Thanks Andrew...

I'll link them to your post and see what they say.

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 6 guests