3

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?

e_i_pi
  • 223
  • 1
  • 2
  • 10
  • "it redirects me" - presumably "it" is the web application? So, there is no way to prevent that happening without changing the web application (or `.htaccess` file) - which is not desirable? How does the web application know to redirect to the IP address - does it simply use the `Host:` header? – MrWhite May 10 '17 at 08:28
  • The `RewriteRule` in .htaccess for the particular web application is redirecting, but it doesn't redirect to `http://11.22.33.44/dev/...`, it redirects to `http://11.22.33.44/`. I want to set the "base" path of the dev environment to the former, not the latter, and I'd rather do that in Apache than fiddle with the .htaccess for the web application. – e_i_pi May 10 '17 at 22:50

0 Answers0