2
votes

I know this question has been asked before, but I haven't found an answer to what I'm running into. I'm trying to redirect a domain (not a sub-domain) to a sub-folder. I'm running IIS 7 and I created a URL rewrite rule like this:

<rule name="subfolder" enabled="true" stopProcessing="true">
    <match url="(.*)" />
    <conditions logicalGrouping="MatchAll">
        <add input="{HTTP_HOST}" pattern="^(www\.)?domain.com$" />
        <add input="{PATH_INFO}" pattern="subfolder" negate="true" />
    </conditions>
    <action type="Rewrite" url="/subfolder/{R:0}" />
</rule>

With the rule off, I can navigate to a page like http://domain.com/subfolder/index.htm. With it on, I get a 403 error when I try to navigate to http://domain.com/index.htm.

403 - Forbidden: Access is denied.

You do not have permission to view this directory or page using the credentials that you supplied.

How do I fix this?

1

1 Answers

2
votes

Try this simple rule:

<rule name="Redirect domain to sub-folder" stopProcessing="true">
    <match url="^$" />
    <action type="Redirect" url="http://domain.com/subfolder" />
</rule>