Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
I think you want to use {REMOTE_ADDR} instead of {REMOTE_HOST} – Frank Jun 30 '12 at 23:50
Take a look at this brief tutorial: learn.iis.net/page.aspx/496/… – Frank Jun 30 '12 at 23:51

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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