All I want to do is map URL
/blog
to/var/www/blog
and the remainder of URL/
to/var/www/site/index
. What is the magical configuration I need for this?
You can easily do this with Apache’s Alias
directive like this. Note that I see you are using Apache 2.4.7 which might have a slightly different syntax than Apache 2.2 and earlier which this advice is based on. But that said, while the syntax might be slightly different but the overall concepts are still the same and I am fairly confident Apache 2.4 still has Alias
functionality.
These items would be set in your main site’s Apache configuration file which would be in /etc/apache2/sites-available/
. Now they might be in a file named /etc/apache2/sites-available/default
or in a separate file for the hostname like /etc/apache2/sites-available/mysite.tld
so be sure to check your config before radically modifying the files.
This would set all requests to http://mysite.tld/blog
to get content from /var/www/blog
:
Alias /blog /var/www/blog
This would set all requests to http://mysite.tld/
to get content from /var/www/site/index
:
Alias / /var/www/site/index
Now that said, you might only need the Alias /blog /var/www/blog
; that second Alias / /var/www/site/index
might not be needed as long as your DocumentRoot
is set to /var/www/site/index
.
A good, simple and concise overview of how Apache config setups work can be found on this site.