Apache local two-level domain name configuration method _linux

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.