Solved

How to redirect home page using IIS7 UrlRewrite

Posted on 2009-07-02
2
669 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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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…

763 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

6 Experts available now in Live!

Get 1:1 Help Now