Okay, so most of you probably already know how to do this, but it only occurred to me today. I develop various websites, usually creating a local version, then uploading it to an online dev version, and finally to the production instance.
In the past, I’d go into my httpd.conf configuration file and change my DocumentRoot to a different website, then restart Apache.
But I realized I could just use a hosts file to point local subdomain to a different folder, e.g. gi.localhost or site2.localhost, or, I could even use the real site’s eventual url: mysite.com or some such.
On my Mac (generally my exclusive machine these days), I edit /etc/hosts and add a line:
Then I make the appropriate changes in /private/etc/apache2/httpd.conf
<Directory /> Options FollowSymLinks AllowOverride All Order deny,allow Allow from all </Directory>NameVirtualHost 127.0.0.1:80 <VirtualHost 127.0.0.1:80> DocumentRoot /Users/mhart/localhost ServerName localhost:80 ServerAlias 127.0.0.1:80 </VirtualHost> <VirtualHost 127.0.0.1:80> DocumentRoot /Users/mhart/gi.localhost ServerName gi.localhost:80 ServerAlias 127.0.0.1:80 </VirtualHost>
In Windows, the hosts file is in c:\Windows\System32\Drivers\etc, and your Apache config file can be found from the Start menu.