I am moving from an Apache host to IIS. One of my sites in Wordpress (running Multi-site) which give me multiple blogs. I have moved all my rules from my .htaccess to the Microsoft URL ReWrite module. I have one section left that will not import.

I want to restrict access to all instances of the file wp-login.php by Client IP address.

In my .htaccess file I did the following:

<Files wp-login.php>
Order Deny,Allow
Deny from all
Allow from 192.168

Any smart ideas on how to accompish this in IIS7.5?


I found this can be done with URL ReWrite

Credit to: http://www.youtube.com/watch?feature=player_embedded&v=ut0pD2l4z5c#!

from web.config

Be sure to add the ServerVariable you choose (HTTP_X_AdminIPAllowed in my example) to allowed server variables from the URL ReWrite module in the IIS Console.

This example allows access to 192.168.1.* clients to all copies of wp-login.php

        <clear />
        <rule name="FlagAdminIPs" patternSyntax="ECMAScript">
            <match url=".*" />
            <conditions logicalGrouping="MatchAny" trackAllCaptures="false">
                <add input="{REMOTE_ADDR}" pattern="^192\.168\.1\.(1(2[8-9]|[3-9][0-9])|2([0-4][0-9]|5[0-4]))$" />
                <set name="HTTP_X_AdminIPAllowed" value="yes" />
            <action type="None" />
        <rule name="Restrict wp-login.php access" enabled="true" stopProcessing="true">
            <match url=".*" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    <add input="{REQUEST_FILENAME}" pattern="wp-login.php" />
                    <add input="{HTTP_X_AdminIPAllowed}" pattern="yes" negate="true" />
            <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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