Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to redirect home page using IIS7 UrlRewrite

Posted on 2009-07-02
2
Medium Priority
?
679 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
richard_crist earned 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
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…

670 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