2

I have a blog hosted on a remote server than our front end. I want to point our http://domain.com/blog into http://blog.domain.com which is where our current blog resides (the virtual host leads to a different machine).

I've tried several ways to do this, but to no avail:

<Location "/blog">
    # Blog proxy
    ProxyPreserveHost On
    ProxyPass /blog http://blog.domain.com # with/without /blog
    ProxyPassReverse /blog http://blog.domain.com # with/without /blog
</Location>

Also outside <Location>:

# Blog proxy
ProxyPreserveHost On
ProxyPass /blog http://blog.domain.com
ProxyPassReverse /blog http://blog.domain.com

Also tried with/without trailing slashes.

Can't get it to work.

I made sure the .htaccess in the http://domain.com/ root is ignoring any rewriterules pointing to $/?blog by using RewriteCond %{REQUEST_URI} !^/?blog, but still nothing. I just get a 404. The directory shouldn't exist, should it?

Any ideas? Thanks!

casraf
  • 21,085
  • 9
  • 56
  • 91

1 Answers1

1

To create a redirect like this you need to configure a apache2 vhost proxy to listen on blog.example.com and to pass the requests to http://example.com/blog

You do this like this:

<VirtualHost *:80> ServerName blog.example.com ProxyPreserveHost On ProxyPass / http://example.com/blog ProxyPassReverse / http://example.com/blog </VirtualHost>

Note: you need to enable the proxy module for apache2 (sudo a2enmod proxy). You need to restart apache2 after enabling the module (sudo service apache2 restart).

Marvin Klar
  • 1,869
  • 3
  • 14
  • 32