This is for IIS6 or IIS7. I want to map a domain to a subdirectory.

For example:

http://www.example.com/dir1/test.aspx

I want to strip out the "http://www.example.com" part and redirect to a relative url, like "proj1/example/dir1/test.aspx". If that won't work, then replace with "http://www.example2.com/proj1/example/dir1/test.aspx. The user's url display must not change.

I know this has been done a million times but I've never worked on this.

link|improve this question

75% accept rate
feedback

1 Answer

up vote 1 down vote accepted

There are two concepts. One is a redirect (client-side) and the other a rewrite (server-side).

A redirect can redirect from one domain to another. But a rewrite must be within the same site. It can't cross domains.

Well, actually you do have an option for cross-domains. That's a reverse proxy like ARR (IIS7 only).

Here's a post on how to rewrite to a different path while retaining the URL in IIS7.

In IIS6 you'll need to use a tool like ISAPI Rewrite www.isapirewrite.com.

link|improve this answer
I used the web.config sample from the post you referred to, edited it for my domains, and it immediately solved the problem. – P a u l Feb 10 '11 at 16:31
Excellent, glad to hear. – Scott Forsyth - MVP Feb 10 '11 at 17:00
feedback

Your Answer

 
or
required, but never shown

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