Introduction: This is a detailed page of the Apache + wildcard domain name resolution tutorial. It introduces PHP, related knowledge, skills, experience, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 327012 'rolling = 'no'>
Let's talk about the problem first. If you have a good understanding of domain name resolution, you can skip this section. In the simplest way, if you want to direct www.yfang.cn to an IP address, you only need to add a record in your management interface, and write the host name www to point to your server IP address.
Suppose you have a domain name called yfang.cn. You can naturally control the DNS pointing of this domain name. This is usually done through the website where you register a domain name.
After a period of domain name proliferation, your own DNS server can correctly find the direction of www.yfang.cn (Ping www.yfang.cn), then the first step of the test is complete.
Next, it is more complicated. Many friends want to implement automatic control for domain name resolution. For example, how does one write the domain name of the famous MSN space?
The connection earlier is like the current look of http://spaces.msn.com/members/yfang is usually like a domain name of http://yfang.spaces.live.com/, the first section is your user name, it looks much better. First of all, you can imagine that adding a record to a 10 N-power account one by one is a two-wise operation for the benefit of the people. When the DNS is configured with a record, the wildcard domain name resolution function is provided, this means that all * .spaces.live.com points to an IP address. The add method is to add a record, * as the host name. Now, let's talk about DNS settings. Next, let's talk about how to correctly configure virtual hosts in Apache.
In fact, this part is also very simple, but it took me dozens of minutes to test. Here I want to write it down to help others.
Assume that you have an Apache site, and there are countless virtual hosts in it. Each virtual host is accessed through port 80, which is differentiated by servername only. Assume that you have created a blog and want to achieve the same effect as MSN space, that is, access through id1.yfang.cn, id2.yfang.cn, and id3.yfang.cn respectively, then you only need to create such a virtual host
<Virtualhost *>
Servername yfang.cn
Serveralias * .yfang.cn
Serveradmin yangfang@fudan.edu.cn
DocumentRoot/var/www/yfang.cn/htdocs
Errorlog/var/www/yfang.cn/logs/error_log
Customlog/var/www/yfang.cn/logs/access_logs combined
</Virtualhost>
Restart Apache and test it.
In this way, you can access abc.yfang.cn and see if the content under/var/www/yfang.cn/htdocsis reached ?!
If it goes well, congratulations. It's a very important step.
Next, there are a lot of methods to prepare websites with similar structures, that is, to direct access to abc.yfang.cn to the correct place. This usually requires a rewrite operation, depending on your directory structure.
Solution 1: You can create a directory for each IDCs under/var/www/yfang.cn/htdocs. after rewrite, you can forward abc.yfang.cn/ to/ABC /.
The two solutions have the same functions and different principles. You just need to understand them.
Now Apache configuration of wildcard domain name resolution is over, and the prince and princess have lived a happy and happy life.
More articles on "Apache + Pan domain name resolution explanation tutorial"
Love J2EE follow Java Michael Jackson video station JSON online tools
Http://biancheng.dnbcw.info/php/327012.html pageno: 12.