I'm looking for a web.config which is equivalent as the .htaccess file below.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REMOTE_HOST} !^123\.123\.123\.123
RewriteCond %{REMOTE_HOST} !^321\.321\.321\.321
RewriteCond %{REQUEST_URI} !/coming-soon\.html$
RewriteRule (.*)$ /coming-soon.html [R=302,L]

Which redirects everyone to a coming soon page except for the given IPs. Unfortunately I'm not familiar with IIS.

  • 1
    I think you want to use {REMOTE_ADDR} instead of {REMOTE_HOST}
    – Frank
    Commented Jun 30, 2012 at 23:50
  • Take a look at this brief tutorial: learn.iis.net/page.aspx/496/…
    – Frank
    Commented Jun 30, 2012 at 23:51

1 Answer 1


Assuming you are using IIS7, what you will want to do is use the IIS URL Rewrite module. With that installed on your server, you can actually import .htaccess mod_rewrite rules directly and it will convert them to the correct syntax and add it to the web.config of your site. Information about that can be found here.

In its raw form, your mod_rewrite rules will be converted to this:

    <rule name="Imported Rule 1" stopProcessing="true">
      <match url="(.*)$" ignoreCase="false" />
        <add input="{REMOTE_HOST}" pattern="^123\.123\.123\.123" ignoreCase="false" negate="true" />
        <add input="{REMOTE_HOST}" pattern="^321\.321\.321\.321" ignoreCase="false" negate="true" />
        <add input="{URL}" pattern="/coming-soon\.html$" ignoreCase="false" negate="true" />
      <action type="Redirect" redirectType="Found" url="/coming-soon.html" />

You will most likely need to test and tune the rule to meet your needs. I believe it was mentioned in a comment about using {REMOTE_ADDR} instead of {REMOTE_HOST}. I do agree with that if you are looking for a specific IP address.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.