Redirect file to URL IIS

With this rewrite rule in your web.config, it’s possible to redirect a user from a specific file to an internal or external URL.
When they enter http://domain.com/folder/filename.html, they will be redirected to http://www.google.com

Note that this requires you have URL Rewrite installed on your IIS.

Place the following rule inside:
[xml]
<system.webServer>
<rewrite>
<rules>

Your rule goes here…

</rule>
</rules>
</rewrite>
</system.webServer>
[/xml]

Rewrite rule:
[xml]
<rule name="Redirect file to external url" stopProcessing="true">
<match url="^~/folder/filename\.html$" />
<conditions>
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
</conditions>
<action type="Redirect" url="http://www.google.com" appendQueryString="false" redirectType="Permanent" />
</rule>
[/xml]

IP restrict Azure website

As for now, it’s not possible to IP/Domain restrict an Windows Azure website from the administration portal. You’ll have to add security rules yourself to web.config associated with your website.

Go to system.webServer section of your web.config and add a security element, if you don’t already have it.
Inside you can configure security rules; “ipsecurity”.
Add the IP address and subnet mask for those IP addresses you want to allow access to your website.
If you need to allow several IP’s, simply duplicate the “ipsecurity” element and edit the IP address.

[xml]
<system.webServer>
<security>
<ipsecurity allowUnlisted="false" denyAction="NotFound">
<add allowed="true" ipAddress="8.8.8.8" subnetMask="255.255.255.0"></add>
</ipsecurity>
</security>
</system>
[/xml]

Gist: https://git.io/vrrEQ/a>

Redirect www to non-www IIS

This guide shows you how to redirect your site from www to non-www on server level with IIS 7.5.

www is actually a subdomain for your main domain (domain.com), which means both www.domain.com and domain.com will serve the same content, if you don’t redirect either www.domain.com to domain.com or the opposite way around. It’s highly recommended to do so, to prevent duplicate content. Which you prefer is entirely up to you, as it doesn’t matter in search engine rankings, as long as you choose one.

Fire up Internet Information Services (IIS) Manager by hitting CTRL+R and type inetmgr [enter]

Choose your site in the left menu and open up “Url Rewrite

Redirect www to non-www IIS

Click “Add rule(s)…”

Choose “Blank rule” under Inbound rules and click [ok]

Redirect www to non-www IIS

Give your rule a name, eg.: Redirect to non-www
Request URL: Match the Pattern
Pattern: (.*)

Open up the “Conditions” tab

Redirect www to non-www IIS

Condition input: {HTTP_HOST}
Check if input string: Does Not Match the Pattern
Pattern: ^domain\.com$ 

Redirect www to non-www IIS

Scroll down to the “Action” tab

Action type: Redirect
Redirect URL: http://domain.com/{R:1}
Make sure Redirect type is set to “Permanent (301)

Redirect www to non-www IIS

Done!

Another option, is to add the rule in your web.config manually:

[xml]
<rewrite>
<rules>
<rule name="Redirect to non-www" stopProcessing="true">
<match url="(.*)" negate="false"></match>
<action type="Redirect" url="http://domain.com/{R:1}"></action>
<conditions>
<add input="{HTTP_HOST}" pattern="^domain\.com$" negate="true"></add>
</conditions>
</rule>
</rules>
</rewrite>
[/xml]