ASP.NET Url Rewrite Subdomain WordPress II7 Web.Config

I have a server that host a variety of asp.net sites on a IIS7 server.
A few of those sites have wordpress blogs in a folder called blog (which is obviously written in PHP). Due to security issues, we need to move those wordpress blogs to a linux server.

So instead of http://www.domainname.com/blog we now have http://blog.domainname.com/ which has the blog url.

Read More

The only problem is, due to SEO reasons, we need the blog to be on the same domain as the main site (which is written in ASP.NET).

My question is, is there a way to do a url rewrite so that if someone types in a wordpress link, similar to this:

http://www.domainname.com/blog/index.php/archives/category/mycategory

Can I use a web config URL rewrite to have the above typed in URL actually point to

http://blog.domainname.com/index.php/archives/category/banking

I can’t do any sort of redirect. It has to be a rewrite, I’ve tried righting one myself but have been unable to. The subdomain is the part of the rewrite I can’t get past.

Has anyone tried to do this before?
Is there some better way I go about this if not.

Keep in mind the blog and the asp.net site cannot be on the same server due to security reasons, but they must keep the same domain name.

Related posts

Leave a Reply

1 comment

  1. You can’t just do a rewrite as the URL you want to rewrite to is on another domain / website. Rewrites only work on the same website.

    You have to setup IIS as a reverse proxy server with the ARR module. In combination with the URL rewrite module you will be able to invisibly forward all requests for http://www.domainname.com/blog/* to http://blog.domainname.com/*.

    Also note that you will have to setup outbound rewriting in order to change back the URL’s that are generated by WordPress (from http://blog.domainname.com/* back to http://www.domainname.com/blog/*).

    See for an example this tutorial: Reverse Proxy with URL Rewrite v2 and Application Request Routing.