Rewriting a URL without the www

Topics: User Forum
Jun 2, 2010 at 4:25 PM

Hi Cheeso

Yes I know this has been covered, but since I upgraded to 2.1 (which I am very happy with), my rule to redirect to a non www URL has stopped working.

My IIRF.ini file looks like this:

# IIRF.ini

RewriteLogLevel 0
RewriteLog  c:\inetpub\iirfLogs\Iirf
RewriteEngine ON
StatusInquiry ON /IirfStatus.htm RemoteOk
IterationLimit 5

# +++++++++++++++++++++++++++++++++

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

RewriteRule (.+\.)(ashx)$                   -                 [L]
RewriteRule ^/([^.?]*)(?<!/)(/\?|\?|/$|$)   /$1/default.aspx  [QSA,L]
RewriteRule ^/(\?|$)                        /default.aspx     [QSA,L]

 The no-www rule was working before!

Any idea why it has stopped?  All I'm getting is "Internet Explorer cannot display the webpage".

Yes, I have the www. as a hostheader in IIS.



Jun 2, 2010 at 6:16 PM
Edited Jun 2, 2010 at 6:17 PM

There was a change between earlier versions of IIRF and v2.1: The default flag character for referring to captures in a RewriteCond changed from % to *.  So I think you should replace %1 with *1. 

Separately, you should lose the L modifier - it's redundant. 

The result should look like this:

RewriteRule ^(.*)$ http://*1/$1 [R=301]
Jun 7, 2010 at 8:27 AM

Perfect, thanks.