The following rule allows us to enable maintenance mode on a site.
Step 1 – Create an app_offline.htm file for the page you want users to see while the website is undergoing maintenance.
Step 2 – Use the following web.config file making sure to change the REMOTE_ADDR pattern to your IP address, and the Redirect line to the full URL of your app_offline.htm file.
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="MAINTENANCE MODE" stopProcessing="true"> <match url="^(.*)$" ignoreCase="false" /> <conditions> <add input="{REMOTE_ADDR}" pattern="^12\.34\.56\.78" ignoreCase="false" negate="true" /> <add input="{URL}" pattern="^/app_offline\.htm$" ignoreCase="false" negate="true" /> <add input="{URL}" pattern="\.(jpe?g?|png|gif|css|js)" negate="true" /> </conditions> <action type="Redirect" redirectType="Temporary" url="http://www.yoursite.com.au/app_offline.htm" /> </rule> </rules> </rewrite> </system.webServer> </configuration>