Link to home
Start Free TrialLog in
Avatar of ddotson
ddotson

asked on

Modify IIS URL Rewrite Rules

I need to configure IIS to redirect all requests for a website (IE www.example.com, or www.example.com/contact, or www.example.com/products, or www.example.com/about/us.html to a specific site:  https://sample.website.com/site/here.

However, if the user enters http://www.example.com/rep, I need it to redirect to http://sample.website.com/secure.

I don't understand the URL rewrite module that well, but I was able to get the redirects working for the naked domain and the rep.  I just couldn't get it to redirect everything to one site, except REP.  

Here's my web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
	<rewrite>
		<rewriteMaps>
			<rewriteMap name="Redirects">
				<add key="/" value="https://www.example.com/public" />
				<add key="/rep" value="https://www.example.com/secure" />
			</rewriteMap>
		</rewriteMaps>
		<rules>
			<rule name="Redirect rule1 for Redirects">
				<match url=".*" />
				<conditions>
					<add input="{Redirects:{REQUEST_URI}}" pattern="(.+)" />
				</conditions>
				<action type="Redirect" url="{C:1}" appendQueryString="false" />
			</rule>
		</rules>
	</rewrite>
    </system.webServer>
</configuration>

Open in new window


How can I modify this?
ASKER CERTIFIED SOLUTION
Avatar of Mrunal
Mrunal
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ddotson
ddotson

ASKER

I forgot about this question, as there was no activity.  I will accept the answer.