Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need to redirect an entire microsite (mymicrosite.com) to relevant pages on my main site (mysite.com).

My main site has a custom 301 module (built into the 404 page) which checks unfound paths against a list of paths where we've moved a page. So if I simply redirect the entire of my microsite at domain level I can handle all the paths from it in the 301 module.

But: I want the index page for my microsite to map to mymainsite.com/section1, instead of to the domain itself.

So mymicrosite.com/product1 > Domain redirect > mymainsite.com/product1 > 404 > 301 Module > mymainsite.com/microsite-product-1

but

mymicrosite.com > Domain Redirect > mymainsite.com

I need

mymicrosite.com > Domain Redirect > mymainsite.com/microsite-products

Can this be done with URL rewrite, and if so, what would the regex look like that would rewrite a domain for all URLs with a domain/path structure but add a path if the URL to redirect contained ONLY the domain?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Yes, you can use the URLRewrite module.

<match url=".*"/>
    <conditions>
        <add input="{HTTP_HOST}" pattern="mymicrosite.com" />
    </conditions>
</match>
<action type="Redirect" url="http://mymainsite.com/microsite-products/{R:1}" 
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.