Adam
Adam

Reputation: 818

Simple IIS 7 URL Rewrite for example.com to domain.com/subfolder

I'm working with IIS7 URL rewriting and I am trying to do a simple URL Redirect with the URL Rewrite module.

I'm trying to redirect

to http://www.domain.com/subfolder

Seems like this should be simple, but I'm fairly new to the URL rewriting module, and apparently I'm missing something.

Upvotes: 2

Views: 10852

Answers (1)

Marco Miltenburg
Marco Miltenburg

Reputation: 6138

You don't say if you want deep links to existing pages to be redirected to the pages in that sub folder. But I assume you want that which will result in this rewrite rule:

<rule name="Redirect traffic to (www.)example.com" stopProcessing="true">
    <match url="(.*)" />
    <conditions>
        <add input="{HTTP_HOST}" pattern="^(www\.)?example.com$" />
    </conditions>
    <action type="Redirect" url="http://www.domain.com/subfolder/{R:0}" appendQueryString="false" />
</rule>

If you don't want to redirect deep links and redirect everything to /subfolder simply remove the /{R:0} part from the URL in the action tag.

Upvotes: 1

Related Questions