Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to redirect home page using IIS7 UrlRewrite

Posted on 2009-07-02
2
Medium Priority
?
681 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
1 Comment
 
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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
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…

824 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