Currently, we have an IIS server as our primary web server. We are implementing an Apache server in its place, but still need to have the IIS server accessible. Typically, this is a simple thing, because Apache2 can proxy a subdomain to this server.

Our problem, however, is this: we are using dotnetCharting on the IIS server, and the licensing is tied to the domain name. In order to get dotnetCharting to work, another license will have to be purchased.

My question is, can Apache2 proxy a subdirectory? For example, can 'www.example.com/subdir' point to the IIS server? It seems like it shouldn't be impossible, but I can't seem to find a solution for this.

4 Answers 4


Sure. But be careful; a lot of web applications aren't designed well for having their URL path change. Is the application used in a sub-directory currently?

# You'll probably want this to maintain the host mapping in IIS
ProxyPreserveHost On
# Swap in the IP address or internal host name of your IIS server:
ProxyPass /subdir/

Or, if you're altering the URL path, keeping in mind that a lot of applications will have problems with this, due to absolute paths for resources (CSS, javascript, images):

ProxyPass /subdir/
ProxyPassReverse /subdir/
  • Perfect! That did the trick in my test environment. Right now, internally, you can enter the server's IP address and use our internal proxy to get to the server, and everything (except dotnetcharting) works perfectly, so I don't expect the application to fail when we proxy it with this method. Much appreciated!
    – Jerbot
    Sep 17, 2012 at 16:40
  • 1
    I had to leave off the trailing / from subdir (like this: /subdir). Otherwise if domain.com/subdir results in an application error (500). It would proxy correctly if the slash was included (domain.com/subdir/), but that's not the effect I was looking for. Jan 5, 2016 at 21:49
  • I didnt quite get what ProxyPreserveHost does? I tried reading in the documentation of apache but still couldnt be sure. So what happens if I set this and i have localserver.com/subdir/ forward the request to remoteserver.com/subdir but that has remoteserver.com/subdir downloading other js,css,html files, the problem I am having is that it is trying to download from localserver.com and those files are only present on remoteserver
    – Murilo
    Aug 18, 2020 at 4:47

the final slash on the end is NOT mandatory. I had it setup like this

ProxyPass /dir http://exmpale.com/dir/ 

ProxyPassReverse /dir http://exmpale.com/dir/ 

and the the top level worked but eveyrything in subdirs beneath the main one did not.

I changed it to this and everything worked.

Thanks for the misinformation!!!

ProxyPass /dir http://exmpale.com/dir

ProxyPassReverse /dir http://exmpale.com/dir
  • 2
    Why do people downvote this? It was exactly the problem I had. You have to either end both urls with a slash or leave both urls without a slash.... atleast for me it helped when it came to sub directories ;)
    – Jannik
    Sep 29, 2018 at 22:30


  1. Enable mod_proxy mod_proxy_http
  2. set the following instruction in your Apache VHost

    ProxyPass /subdir http://iis.server/.../
    ProxyPassReverse /subdir http://iis.server/.../

Note the final "/" is mandatory.

For moreinformation: http://httpd.apache.org/docs/2.2/mod/mod_proxy.html


I found the following works while it doesn't with trailing / :

ProxyPass /dir http://exmpale.com/dir
ProxyPassReverse /dir http://exmpale.com/dir

while this (don't mind the protocol) only works with trailing / :

ProxyPass / ajp://server.ip.address:8009/
ProxyPassReverse / ajp://server.ip.address:8009/

I would not say

Note the final "/" is mandatory.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .