Rewriting IIRF url to force prefix www: example.com & # 8594; www.example.com

I am trying to do something pretty simple in iirf.

I want all requests to be missing from www. prefix to add it.

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 tests are ignored:

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

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

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

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

      

Thank,

Ashley

+2


source to share


2 answers


TestDriver is a standalone tool for testing rewrite rules for IIRF. Unfortunately, the tool is limited because it cannot efficiently evaluate the conditions that server variables are validated. There are no server variables in a standalone console application.

Check the document . Here's what he says:



Please note that TestDriver.exe is a useful testing tool, but it cannot and cannot replace actual testing in the context of a web server. The test drive does not run in the context of an HTTP server and therefore does not work with HTTP server variables. Specifically, if you use RewriteCond on ini files that you are testing with TestDriver.exe, and those RewriteCond statements refer to server variables (for example,% {HTTP_URL} or% {HTTP_REFERER}), then those RewriteCond statements will not behave in TestDriver they will behave the same in ISAPI. Tests of these conditions will not be useful in verifying actual performance.

+1


source


You need to provide an absolute URL to substitute. Otherwise, yours is www.example.com

treated as a path segment.



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

      

0


source







All Articles