Solved

How to redirect home page using IIS7 UrlRewrite

Posted on 2009-07-02
2
676 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 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

Suggested Solutions

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
A phishing scam that claims a recipient’s credit card details have been “suspended” is the latest trend in spoof emails.
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…

735 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