I use my own domains (ended with .lc) for development web application on localhost. I will describe simple solution for dynamic .lc domains and development enviroment that works without dependency on internet connection.
I wrote about it on my blog too: http://www.michalseidler.com/development/localhost-development-enviromet-for-php/
For this example i try describe configuration of local dynamic domains *.lc with Wamp Server. I have my projects stored in C:\wamp\www\projects\projectname\ and i use dynamic maping projectname.lc. This means that i can access every project directory with domain [project direktory name].lc
Step 1 – configuration of local WAMP server
First of all you need place configuration of *.lc domain into httpd.conf:
<VirtualHost 127.0.0.1>
ServerName lc
ServerAlias *.lc
DocumentRoot "C:\wamp\www\projects"
</VirtualHost>;
You need insert .htaccess file into projects direktory (in my example into: C:\wamp\www\projects) this configuration maps *.ls domains to project direktories. Ex.: If you have sources in direktory ‚myapp‘ you can use www.myapp.lc to open it in browser.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^([^\.]*)\.([^\.]*)$
RewriteRule (.*) http://www.%1.%2/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.([^.]+)\.([^\.]*)$ [NC]
RewriteRule ^(.*)$ http://%1.%2.%3/$1 [L,R=301]
RewriteCond %{REQUEST_URI} !^projects/
RewriteCond %{REQUEST_URI} !^/projects/
RewriteCond %{HTTP_HOST} ^(www\.)?(.*)\.([^\.]*)\.([^\.]*)$
RewriteRule (.*) %3/$1 [DPI]
After this changes restart Wamp Server
Step 2 – configuration of local DNS server
Because we can’t use *.lc in Windows host file we need instal local DNS server. I choose Acrylic DNS Server because it is very simple for configuration.
After instalation find AcrylicHosts file (C:\Program Files (x86)\Acrylic DNS Proxy) and insert new line:
127.0.0.1 *.lc
This is only DNS configuration we need so restart Acrylic DNS service.
Step 3 – configuration of network adapter
Final step is install new fake network adapter and assign DNS server:
1.Click the Start menu.
2.Search for “cmd“.
3.Right-click on “cmd” and select “Run as Administrator”
4.Enter “hdwwiz.exe”
5.In the „Welcome to the Add Hardware Wizard“, click Next.
6.Select „Install the hardware that I manually select from a list (Advanced)“ and click Next.
7.Scroll down and select „Network adapters“ and click Next.
8.Select under Manufacturer „Microsoft“ and then under Network Adapter „Microsoft Loopback Adapter“ and click Next.
In next step you must change TCP/IP settings of new created adapter:
1.Log on to the computer by using the Administrator account.
2.Click Start, point to Control Panel, and click Network Connections.
3.Right-click the Loopback connection and then click Properties.
4.In the This connection uses the following items box, click Internet Protocol (TCP/IP), and then click Properties. The Internet Protocol (TCP/IP) Properties dialog box appears.
IP addess: 192.168.1.1
Subnet mask: 255.255.255.0
Default Gateway: empty
Prefered DNS server: 127.0.0.1
Now close all dialogs and its done! You can try open [your project name].lc