Question

I currently use mod_vhost_alias with a wildcard ServerAlias to catch all subdomains for the domain I use to hold development versions of websites.

This works great, but I reach an issue when I need to test websites that have 'm.' subdomain flexibility for mobile versions. In a live environment, this subdomain would still use the same directory as the normal domain, but I am unable to achieve this in development.

Example:

website.devdomain.com goes to /var/www/website.devdomain.com, and m.website.devdomain.com goes to /var/www/m.website.devdomain.com, but preferably this should go to /var/www/website.devdomain.com

Is there a way to make sub-subdomains go to their parent's directory? The current VirtualDocumentRoot snippet I use is VirtualDocumentRoot /var/www/%0/

I can create custom document roots on a per-site basis to achieve this, but if there is an automated way with VirtualDocumentRoot it would be much more practical.

Was it helpful?

Solution

I used to have the same problem, and found a simple solution: Symbolic Links!

If you're using a Linux system, you can create a symbolic link from your mobile document root to your main document root, like so:

ln -s /var/www/example.com /var/www/m.example.com

If you're on Windows, the solution is a little trickier, since Windows doesn't have an easy symlink command.

mklink /D C:\var\www\m.example.com c:\var\www\example.com

Note that the Windows version parameters are backwards from the Linux ones; Go figure.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top