COV-Webmaster
asked on
Setup IIS 7.5 URL Rewrite to redirect root request to index.htm
I have several re-write rules setup using the IIS 7.5 URL Rewrite add-on. All of the re-writes are working fine. Currently with all of these re-writes enabled, when a user requests http://domain.com/ they are being redirected to another server. I want them to be re-directed to another server when they match one of my other regular expressions. When a user does not enter in anything (ie: hits the root of the site http://domain.com/ ), I want them to be transferred to the index.htm file on the same server. Something like this could easily be done using the Apache Mod Rewrite using a regex like "^/", however, IIS 7.5's seems to match the URL path after the first "/" that is requested.
Is there any way to do this? Below is what I have tried so far.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Index Request" enabled="true" stopProcessing="true">
<match url="^/" />
<conditions>
<add input="{REQUEST_URI}" pattern="^/" />
</conditions>
<action type="Redirect" url="http://domain.com/index.htm" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Any suggestions?
Is there any way to do this? Below is what I have tried so far.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Index Request" enabled="true" stopProcessing="true">
<match url="^/" />
<conditions>
<add input="{REQUEST_URI}" pattern="^/" />
</conditions>
<action type="Redirect" url="http://domain.com/index.htm" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Any suggestions?
ASKER
Thanks Kaufmed. It would make sense that that would work, but for whatever reason it doesn’t.
This is what I tried:
This is what I tried:
<rule name="Index Request" enabled="true" stopProcessing="true">
<match url="^/" />
<conditions>
<add input="{REQUEST_URI}" pattern="^$" />
</conditions>
<action type="Redirect" url="http://domain.com/index.htm" logRewrittenUrl="true" />
</rule>
Now that I think about it, why wouldn't you just specify the "default document" to be index.htm ?
ASKER
The index.htm is specified as the default document. The URL Rewriting rules are processed before the default document or any document is loaded. The default document is never loaded because I have other rules in place.
>> The URL Rewriting rules are processed before the default document or any document is loaded.
Right, but if the user doesn't supply a URI (i.e. they go to the website root), then none of the rules should match, and the default document should be loaded. I could be missing something though.
Right, but if the user doesn't supply a URI (i.e. they go to the website root), then none of the rules should match, and the default document should be loaded. I could be missing something though.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Cool. Glad you found a solution = )
ASKER
This rule works.
Open in new window