Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serve multiple directories with Apache

Tags:

I am running Apache on Ubuntu. My /var/www folder consists of two directories

/codeigniter /wordpress 

I would like mydomain.com to point to /codeigniter and mydomain.com/blog to point to /wordpress. I have acheived the first one but not the second.

I have the following in site-available/mydomain.com

<VirtualHost *:80>   ServerAdmin [email protected]   ServerName  www.mydomain.com   ServerAlias mydomain.com    # Index file and Document Root (where the public files are located)   DirectoryIndex index.html index.php   DocumentRoot /var/www/codeigniter/public    <Directory "/var/www/codeigniter/public">   Options FollowSymLinks   AllowOverride All   Order allow,deny   Allow from all   </Directory> </VirtualHost> 

This works and when I go to mydomain.com in my browser it takes me to my codeigniter directory. However how can I make apache take me to my wordpress directory when I go to mydomain.com/blog?

like image 487
Pattle Avatar asked May 07 '13 22:05

Pattle


People also ask

Can Apache Host multiple Websites?

Apache Virtual Hosts are a feature which let you host multiple independent websites from one Apache installation. Each site has its own filesystem directory and domain name. You can serve different sites to different visitors based on the domain they're using.

What is IfModule in Apache?

<IfModule> is simply a directive that tests the condition "is the named module loaded by apache httpd" (in your example mod_expires). It allows people to produce conditional based configuration for different installations where certain modules may be present or not.


1 Answers

Simple, add an Alias and another directory block inside your VirtualHost block:

Alias /blog/ "/var/www/wordpress/" <Directory "/var/www/wordpress/">     ... whatever you want ... </Directory> 
like image 162
daiscog Avatar answered Sep 17 '22 16:09

daiscog