Reputation: 15950
I was already running a sub-website under following path
Now, I have created a sub-domain
Require "web.config" file code that can do 301 in following way
Request Redirect to
--------------------------------------------------------------------------
http://example.com/sub-site/ http://sub-site.example.com/
http://example.com/sub-site/page-1.html http://sub-site.example.com/page-1.html
http://example.com/sub-site/page-2.html http://sub-site.example.com/page-2.html
.
.
.
http://example.com/sub-site/page-N.html http://sub-site.example.com/page-N.html
Basically, rule should be written in such a way that "http://example.com/sub-site/" is changed to "http://sub-site.example.com/" in request, and browser should be redirected to newer location.
Upvotes: 2
Views: 3226
Reputation: 11706
This should work.
<rewrite>
<rules>
<rule name="redirect to subdomain" stopProcessing="true">
<match url="(.*)" />
<action type="Redirect" url="http://sub-site./{R:1}" appendQueryString="false" />
<conditions>
</conditions>
</rule>
</rules>
</rewrite>
Upvotes: 2