Unable to force www in url

Topics: Developer Forum, Project Management Forum, User Forum
Jun 12, 2008 at 11:26 AM
Edited Jun 12, 2008 at 1:15 PM
Hello,
I am trying to force www in URL using latest version of IIRF so that :
1> http://mydomain.com should go to http://www.mydomain.com
2> http://mydomain.com/bar.html should go to http://www.mydomain.com/bar.html
3> http://mydomain.com/foo/bar.html should go to http://www.mydomain.com/foo/bar.html

I tried using URL rewite tip found here : http://www.codeplex.com/IIRF/Thread/View.aspx?ThreadId=16990

Which uses following :

RewriteCond %{HTTP_HOST} ^mydomain\.com [I]

RewriteRule ^/(.*) http://www.mydomain.com/$1 [R=301,I]

but this is not working as i tried testing it with testdriver.

Any clue whats wrong here?

thanks for your help in advance






Coordinator
Jun 12, 2008 at 1:47 PM

Yes.  I have a clue.

the short version:  ReadMe.txt.

The long version:

Please note: 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}) , those RewriteCond statements will not behave in the testDriver the same way they will behave in an ISAPI. Likewise, if you reference server variables in the replacement pattern, it won't work the way you might hope. In general, it is difficult to use testdriver to evaluate any ruleset that relies on HTTP Server variables.

---
In your particular circumstance, you are relying on the HTTP_HOST server variable in the RewriteCond.  This won't evaluate to anything in the testdriver context.  It won't work.   To test rulesets that involve server variables, you will need to install and run the ISAPI in IIS, and you need to run real URLs through the filter.  

Jun 12, 2008 at 1:58 PM
Even i thought so ;)

But i also tried out rewrite rules in live site & still IIRF was not doing redirect.

Could you please confirm if above mentioned rewrite rules are correct ?

Thanks for your reply.




Coordinator
Jun 12, 2008 at 3:24 PM

the rules look ok.  But it's not my opinion that matters.  It's the FILTER.

What do the logs say on the live site?

Jun 12, 2008 at 6:00 PM
Fixed the problem.by using 1.2.12c release.

Plus i had to allow extension (IsapiRewrite4.dll) in Allowed Server Extensions settings in IIS.

This thread can now be closed