I'm in the process of migrating from an old Debian 6 server to a nice new shiny Ubuntu 16.04 server. On our Debian server, we have the main domain but also several subdomains (each of which has a .conf file), such as:
On the new server, because we haven't yet got a domain name pointing to the IP address, but we have to test the migrated sites, I've used the following .conf file:
<VirtualHost *:80>
ServerAdmin serveradmin@example.com
Alias /prod /var/www/example.com/web
Alias /dev /var/www/dev.example.com/web
Alias /db /var/www/db.example.com/public_html
DirectoryIndex index.php
</VirtualHost>
So, if I want to go to the home page in each environment, I use these URLs:
Now, in the dev site, I have pretty URL redirect rules such as:
RewriteRule ^pretty-url /path/to/content [L,R=301]
The problem is, if I navigate to http://11.22.33.44/dev/pretty-url
, it redirects me to http://11.22.33.44/path/to/content
, not http://11.22.33.44/dev/path/to/content
.
Given that I can't use a directive such as ServerName dev.11.22.33.44
or ServerName 11.22.33.44/dev
, and I don't want to alter the .htaccess files in the web directories - what should my .conf files look like to allow multiple "sites" on the IP address, each of which maps to a subdirectory and rewrites correctly to that subdirectory?