Routing a url to fetch content from another site

292 views Asked by At

Environment: IIS 7.

  • I have a default site www.domain.com. Folder C:Inetpub/wwwroot/domain
  • There is subdomain www.subdomain.domain.com. Folder C:Inetpub/wwwroot/domain/subdomain.
  • Now, I have set up a new website at an external server, say www.newdomain.com. I cannot host www.newdomain.com on the same IIS server (as mentioned above) due to some constraints.

In this setup, how do I get www.subdomain.domain.com/blog to show all the content available on www.newdomain.com while preserving the URL as www.subdomain.domain.com/blog

How could this be achieved in IIS 7?

3

There are 3 answers

0
Kevin P. Rice On

You would have to put the entire www.subdomain.domain.com on the other server. You can't put just the /blog path somewhere else.

How would any client know to go to that other server for /blog if the DNS for the subdomain points to the first server?

Alternatively, you could create blog.subdomain.domain.com for the blog server.

0
Saurabh Nanda On

Possible approaches:

  • Host the new website as blog.domain.com with the actual content hosted on a different server (not the same IIS server as domain.com)
  • Set-up a ProxyPass on subdomain.domain.com/blog to the new website. I know how do to this on Apache (via mod_proxy and ProxyPass), but not sure how to do this with IIS. Probably ARR can help you.
0
Abhishek On

I was finally able to do this by reverse proxy rewrite rule. For those who have similar trouble here is the solution:

Go to the site node hosting www.subdomain.domain.com and click rewrite rule. If ARR is not installed the IIS Manager will ask you to install it. After installing ARR close and reopen the IIS Manager.

Open the rewrite rule window. There will be a dialog asking to allow reverse proxy to servers outside your server farm, accept that. In the Inbound rule enter www.newdomain.com. In the from input of the Outbound rule enter www.newdomain.com and in the to input enter www.subdomain.domain.com. click apply changes.

This will route the entire www.subdomain.domain.com to newdomain.com. What you need is to route only the /blog link.

To do this go to rewrite rules and select the rewrite rule you just created. Click edit and in the match section in url input change (.asterix) to ^blog(.asterix). This will apply the rule to route only the /blog.

That all. test your routing in the browser, if everythings fine this should work.