views:

899

answers:

2

Hi there,

I'm trying to do something pretty simple in iirf.

I want all requests that are missing the www. prefix to have it added.

This is my IsapiRewrite4.ini:

RewriteCond %{HTTP_HOST} ^example\.com$ [I]
RewriteRule ^(.*)$ www.example.com/$1 [R=301,L]

This is my SampleUrls.txt:

example.com
example.com/grants
www.example.com
www.example.com/grants

I place the files in the same directory as TestDriver.exe, and run testdriver -d . All the tests are ignored:

NO ACTION 'example.com' ==> --

NO ACTION 'example.com/grants' ==> --

NO ACTION 'www. example.com' ==> --

NO ACTION 'www. example.com/grants' ==> --

Thanks,

Ashley

A: 

You need to specify an absolute URL for the substitution. Otherwise your www.example.com is treated as path segment.

RewriteCond %{HTTP_HOST} ^example\.com$ [I]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
Gumbo
Hi Gumbo,I tried your suggestion to no avail. The TestDriver tool still doesn't match any of tests.hmmm...
Ash Kim
+1  A: 

The TestDriver is a standalone tool to test rewrite rules for IIRF. Unfortunately, the tool is limited, in that it cannot effectively evaluate conditions that test Server variables. There are no server variables in a standalone console-based application.

Check the doc. Here's what it says:

Please note: the TestDriver.exe program is a useful testing tool, but it does not and cannot replace actual testing in the context of a web server. The testdriver does not run within the context of an HTTP server, and so does not work with HTTP Server variables. In particular, if you use RewriteCond in the ini files that you test with TestDriver.exe, and those RewriteCond statements reference Server variables (eg %{HTTP_URL} or %{HTTP_REFERER}) , those RewriteCond statements will not behave in the TestDriver the same way they will behave in an ISAPI. Tests of such conditions will not be useful in verifying actual operational performance.

Cheeso