This article describes the Apache local two-level domain name configuration method. Share to everyone for your reference, specific as follows:
When we debug a Web program locally, we often have many different projects. For different items, we want to use different folders and different domain names.
For example, today I am building a flower site, but a customer temporarily to do a simple selling glasses of the site, two sites on the computer in a different directory, and to use two different domain names to access. One is flower.domain.com, one is glass.domain.com.
Normally, we should do this:
1, in the local hosts file, will flower.domain.com point to 127.0.0.1
2, in IIS or Apache, will flower.domain.com binding, and point to the appropriate local folder;
Although this process is not very complex, but we have a lot of business, we hope to be more convenient to achieve it.
Now in this way, no matter how many businesses you add, all you have to do is just add your folders.
From then on, you no longer need to make any settings, much less require any programs to restart.
Method:
In the Apache configuration file, the last side adds the following:
Rewriteengine on
rewritecond%{http_host} [^.] +\.lvh\.me$
rewriterule ^ (. +) $%{http_host}$1 [C]
rewriterule ^ ([^.] +) \.lvh\.me (. *) $/$1$2
OK, you can use *.lvh.me to access all your catalogs.
If you enter flower.lvh.me, it points to a directory that is equivalent to: http://127.0.0.1/flower
If you enter glass.lvh.me, it points to a directory that is equivalent to: Http://127.0.0.1/glass
I hope this article will help you with your Apache server settings.