Skip to content →

How to redirect http requests to a virtual host

In the contex of redirecting I saw some jaw-dropping configuration in regards to proxying to a physical path. System engineers tried to redirect on a virtual host from the root to a given path “wp”. I assume that was WordPress.

Why would one do something like this?

ProxyPass / http://127.0.0.1/wp
ProxyPassReverse / http://127.0.0.1/wp

I think it’s the misconception of how one should configure a server in Apache.

Apache Web Server document root adaption

This will route any traffic from the website, let’s say www.johndoe.com to your local server. But the hostname should be part of the “ServerName” attribute. So, you just trimmed that essential attribute. Your request will run no-where, unless the IP is mapped to the exact same directory.

Anyhow, simply extend the path of the document root. In this case with “wp”.  There is no ProxyPass needed.

DocumentRoot "/var/www/vhosts/johndoe.com/httpdocs/wp"

Published in Uncategorized

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *