IIS Rewrite Rule for Redirect to Directory

Microsoft Dynamics GPThe web hosat I am currently with allows multiple domains, but only 6 websites; this means I have to be a little creative sometimes when creating additional sites.

I actually have a lot more than six websites being hosted on my account, due to a mix of WordPress MU and redirects to folders.

The redirect is done using an IIS rewrite rule. As I may be moving web host soon, I’m posting this so that I have easy access should I need.

This code goes in the rewrite section of the web.config file:

/*
Created by Ian Grieve of azurecurve|Ramblings of a Dynamics GP Consultant (https://www.azurecurve.co.uk)
This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int).
*/
<rewrite>
	<rules>
		<rule name="Rewrite subdomain.azurecurve.co.uk subdomain to dir" enabled="true">
			<match url="^(.*)$" />
			<conditions>
				<add input="{HTTP_HOST}" pattern="^subdomain\.azurecurve\.co\.uk$" />
			</conditions>
			<action type="Rewrite" url="_subdomain.azurecurve.co.uk/{R:1}" />
		</rule>
		<rule name="subdomain.azurecurve* wordpress" patternSyntax="Wildcard">
			<match url="*subdomain.azurecurve*" />
			<conditions>
				<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
				<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
			</conditions>
			<action type="Rewrite" url="_subdomain.azurecurve.co.uk/index.php" />
		</rule>
</rewrite>

The second rule is, I believe, required specifically for redirects for WordPress sites, the majority of which my rewrites are for.

What should we write about next?

If there is a topic which fits the typical ones of this site, which you would like to see me write about, please use the form, below, to submit your idea.

Your Name

Your Email

Suggested Topic

Suggestion Details

Looking for support or consultancy with Microsoft Dynamics GP?

I no longer work with Microsoft Dynamics GP, but the last company I worked for was ISC Software in the UK; if you’re looking for support or consultancy services with Microsoft Dynamics GP you can contact them here.

Leave a Reply

Your email address will not be published. Required fields are marked *