Solved

How to redirect home page using IIS7 UrlRewrite

Posted on 2009-07-02
2
671 Views
Last Modified: 2013-11-08
I am trying to redirect my  home page to a subdirectory using IIS7's new UrlRewrite engine. I can't seem to properly redirect root requests to the subdirectory. It works fine, until it conflicts with the 2nd rewrite rule.

When I go to http://mail.mydomain.com, it takes me to http://mydomain.com/mail/store. It shouldn't add the /store directory because /mail is not the root (although it is a virtual applications). How can I handle only root requests?
<rule name="Redirect-Home" enabled="true" stopProcessing="true">

                    <match url="^$" />

                    <action type="Redirect" url="/store" appendQueryString="false" redirectType="Found" />

                </rule>

                <rule name="Mail" enabled="true" stopProcessing="true">

                    <match url="^(.*)$" />

                    <conditions logicalGrouping="MatchAll">

                        <add input="{HTTP_HOST}" pattern="^(mail)\.(.*)$" />

                    </conditions>

                    <action type="Redirect" url="https://{C:2}/{C:1}{PATH_INFO}" redirectType="Found" />

                </rule>

Open in new window

0
Comment
Question by:bemara57
2 Comments
 
LVL 3

Accepted Solution

by:
richard_crist earned 500 total points
ID: 24805710
I'm just perusing around the open questions and found this one.  I don't know anything about this stuff (IIS7 UrlRewrite) but to me it appears that your processing is encountering "http://mail.mydomain.com" and changing it to "http://mydomain.com/mail" for redirection.  The redirection then encounters the "http://mydomain.com/mail".  Since "http://mydomain.com/mail" does not start with "mail" it then appends the "/store".

Now...stopProcessing is true on both of your rules....and appendQueryString is false on the "/store" rule.  I am not sure if the order of the rules matters (you have the "/store" rule first) but my uninformed opinion is that the processing is happening as stated in my first paragraph above, and the redirection to "/store" is happening but the root for "/store" is now "http://mydomain.com/mail" so you end up with "http://mydomain.com/mail/store".

Maybe my possibly totally wrong take on the situation will help.   :)
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now