Implementation in secondary domain

2010-02-24  来源:本站原创  分类:Internet  人气:244 

With the optimization of the depth and maturity of the Internet, two domain names and web sites for independent of the relationship between the primary domain name more and more subtle; this evolving trend will gradually mature.

Which saw a lot of people in je blog two domain names to resolve implementation mechanism, it is good enough!

Reproduced here, a number of further points in the summary as a backup.

★ ★ ★ reference here is to use tomact reproduced part of the way to achieve: "http://stephen830.javaeye.com/blog/277522" ★ ★ ★

Before you begin, first of all to understand what is 2 under the domain name?

Generally, we register a domain name, such as www.javaeye.com (the following examples are javaeye.com domain name, of course, this is only example, the domain name has already been registered!), Then this is your one domain (TLD) , is fixed and only one, but as robin.javaeye.com, stephen830.javaeye.com so that a domain name is your level 2 under the name of the. Therefore, each an infinite number of domain name can have the following two domain names as long as you meet the definition of rules of international domain names.

More and more websites offer two domain features, as JavaEye, as long as you register as a user, you can get a spot of their own two domain names. Possible, perhaps you think the mystery of which is that this feature would be more complicated to achieve, on the contrary, reading Le this article, I believe you can easily create your own dynamic two domain effects.

The following step by step, let us look at how to achieve it!

Step 1 You should prepare a one domain name (international domain name, the domestic domain can), and where your domain name dns server domain to support the pan-analytic functions, take javaeye.com, the pan-analysis is a.javaeye.com / b.javaeye.com / c.javaeye.com /..., javaeye.com all these point to the same set ip address, with this function, the domain name to achieve the dynamic two domain names. General dns server domain name service provider has this feature.

You only need to add the configuration in the domain name beginning with a *. records, analysis of the pan can be achieved. After configuration, you can test with the ping command, assuming your domain name is javaeye.com, you can run ping a.javaeye.com, if supported through the words of the resolution of the pan. (Of course, pay attention to some of the host server screen ping echo!)

Step 2 Prepare your WEB application, where the use of the tomcat, in tomcat's server.xml configuration file for configuration:

Xml Code
<Host Name="localhost" debug="0" appBase="/www/doc" unpackWARs="true" autoDeploy="true">
<Logger ClassName="org.apache.catalina.logger.FileLogger" directory="logs" prefix="www." suffix=".txt" timestamp="true"/>
</ Host>

<Host Name="localhost" debug="0" appBase="/www/doc" unpackWARs="true" autoDeploy="true">
<Logger ClassName="org.apache.catalina.logger.FileLogger" directory="logs" prefix="www." suffix=".txt" timestamp="true"/>
</ Host>

WEB which appBase configure their application position, name = "localhost", said the root directory, all access the host will automatically configure the application to appBase. Suppose your domain host address 202.109.xx.xx, then enter directly in the browser will default to open your http://202.109.xx.xx above configuration that web application, this how your host When a WEB application to be careful. You add other independent WEB application (assuming there is a WEB application is www.xxx.com) when the configuration like this:
Xml Code
<Host Name="www.xxx.com" debug="0" appBase="/www/doc/xxx" unpackWARs="true" autoDeploy="true">
<Logger ClassName="org.apache.catalina.logger.FileLogger" directory="logs" prefix="www.xxx.com." suffix=".txt" timestamp="true"/>
</ Host>

<Host Name="www.xxx.com" debug="0" appBase="/www/doc/xxx" unpackWARs="true" autoDeploy="true">
<Logger ClassName="org.apache.catalina.logger.FileLogger" directory="logs" prefix="www.xxx.com." suffix=".txt" timestamp="true"/>
</ Host>

This independent www.xxx.com domain name must be used to access, can not use the ip address to access the site.

Step 3 In order to better show the dynamic effect of two domain names, use a frame as a WEB application index.html, the index.html will be the home of your WEB application surface. (Note: The index.html is not necessary, just to make the browser address bar, it was more beautiful)

index.html

Html code
<! DOCTYPE HTML PUBLIC "- / / W3C / / DTD HTML 4.01 Transitional / / EN">
<html>
<head>
<title> - </ title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<head>
<frameset framespacing="0" border="0" rows="0,*" frameborder="0">
<frame name="" noresize scrolling="no" target="_self" src="" frameborder="0" marginheight="0" marginwidth="0">
<frame name="" scrolling="auto" target="_self" src="index.jsp" frameborder="0" marginheight="0" marginwidth="0">
<noframes>
<body>
<p> your browser version is too low, need to upgrade to use this system! </ P>
</ Body>
</ Noframes>
</ Frameset>
</ Html>

<! DOCTYPE HTML PUBLIC "- / / W3C / / DTD HTML 4.01 Transitional / / EN">
<html>
<head>
<title> - </ title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<head>
<frameset framespacing="0" border="0" rows="0,*" frameborder="0">
<frame name="" noresize scrolling="no" target="_self" src="" frameborder="0" marginheight="0" marginwidth="0">
<frame name="" scrolling="auto" target="_self" src="index.jsp" frameborder="0" marginheight="0" marginwidth="0">
<noframes>
<body>
<p> your browser version is too low, need to upgrade to use this system! </ P>
</ Body>
</ Noframes>
</ Frameset>
</ Html>

Step 4 The two dynamic domain name.

Suppose the user on the site (www.javaeye.com) registered a user, the user name such as test, so long as the browser type test.javaeye.com after the treatment will be as follows.

Enter test.javaeye.com, first to resolve test.javaeye.com the two domain name ip address, such as input http://202.109.xx.xxx/ the same effect (assuming javaeye.com the ip to 202.109. xx.xxx); and then will go to visit the domain page of the corresponding surface WEB application, which is above the configured index.html, and then calls the following index.jsp

This jsp is responsible for is the real dynamic two Domain Name and address of the index.jsp

Html code
<% @ Page contentType = "text / html; charset = UTF-8"%>
<%
String host = request.getHeader ("Host"). Trim ();// get visitors to a domain name, here are two if the domain name, you get such test.javaeye.com, test is the registered user name
String [] hosthosts = host.split ("[.]");
if (hosts.length == 3) (/ / only deal with information of length 3
if ("javaeye". equals (hosts [1 ])&&" com ". equals (hosts [2 ])){// determine whether the two domain names is javaeye.com
String name = hosts [0]. Trim ();
if (! "www". equals (name )){// www is the domain name itself is used, can not be used said the two domain names, so when the user registered as www, ftp, mail, smtp, pop and other key words do not are registered to the user.
/ / In this position must also use a method to verify the legality under the name, such name must be a registered site user, the user name and Web site data verification table
/ / Validation passed, corresponding to the processing page response.sendRedirect ("self.jsp? Name =" + name); / / 2 level domain turn a handle to the specified file, if there is self.jsp
return;
)
)
)
%>
<! DOCTYPE HTML PUBLIC "- / / W3C / / DTD HTML 4.01 Transitional / / EN">
<html>
<head>
<title> - </ title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</ Head>
<body bgcolor="#ffffff" topmargin="80px" leftmargin="20px" rightmargin="20px">
<! - Home side content ->
</ Body>
</ Html>

<% @ Page contentType = "text / html; charset = UTF-8"%>
<%
String host = request.getHeader ("Host"). Trim ();// get visitors to a domain name, here are two if the domain name, you get such test.javaeye.com, test is the registered user name
String [] hosts = host.split ("[.]");
if (hosts.length == 3) (/ / only deal with information of length 3
if ("javaeye". equals (hosts [1 ])&&" com ". equals (hosts [2 ])){// determine whether the two domain names is javaeye.com
String name = hosts [0]. Trim ();
if (! "www". equals (name )){// www is the domain name itself is used, can not be used said the two domain names, so when the user registered as www, ftp, mail, smtp, pop and other key words do not are registered to the user.
/ / In this position must also use a method to verify the legality under the name, such name must be a registered site user, the user name and Web site data verification table
/ / Validation passed, corresponding to the processing page response.sendRedirect ("self.jsp? Name =" + name); / / 2 level domain turn a handle to the specified file, if there is self.jsp
return;
)
)
)
%>
<! DOCTYPE HTML PUBLIC "- / / W3C / / DTD HTML 4.01 Transitional / / EN">
<html>
<head>
<title> - </ title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</ Head>
<body bgcolor="#ffffff" topmargin="80px" leftmargin="20px" rightmargin="20px">
<! - Home side content ->
</ Body>
</ Html>

In this way, you can easily realize the dynamic function of the two domain names.

Last description: this article only a dynamic two enlightening articles domain name, hoping to tell all your friends, the dynamic two domain name is not at all complicated, but you may not have found At present way, the truth that they have now understood.
If you want to name the dynamic two commercial / product oriented, but also requires further improvement, we can improve the way information on the Internet Zhao Zhao. Basically, each container has its own WEB some specific configuration to achieve this functionality.

apach program:
Apache settings:
<VirtualHost *:80>
ServerName union.abc.com
ServerAlias *. test.org
DocumentRoot "D: \ mywork \ Test \ ROOT"
<Directory "D:\mywork\Test\ROOT">
Options Indexes MultiViews
AllowOverride None
Order allow, deny
Allow from all
</ Directory>
DirectoryIndex index.htm
</ VirtualHost>

Methods:
Main do first pan-Domain Name. (Domain registrar)

A record of new *. xxx.com-> xxx.com

Well, all the analysis of all your pages to xxx.com. Means that you use aaa.xxx.com. Bbb.xxx.com are into the xxx.com may default home page has gone, so OK music.

And then through request.getRequestURI () to get the request URL and then split ("."), then get aaa, bbb, compared to the database, and then foward to the corresponding url to, OK.

相关文章
  • Implementation in secondary domain 2010-02-24

    With the optimization of the depth and maturity of the Internet, two domain names and web sites for independent of the relationship between the primary domain name more and more subtle; this evolving trend will gradually mature. Which saw a lot of pe

  • A VPS, a top-level domain, an independent IP, how to configure multiple secondary domain name sites? 2010-08-31

    Hire a new web VPS, only one top-level domain, an independent IP, how to configure multiple secondary domain name sites? If the top-level domain name: www.AAA.com Site visit required: a.AAA.com as an independent web site b.AAA.com for another indepen

  • kiccp.com opening of the new secondary domain name 2011-05-08

    Today, the domain name for my secondary domain name kiccp.com enabled: blog.kiccp.com , published as a blog site KICCP information and some of my personal log.

  • nginx secondary domain name matches the root directory of the sub-folders 2010-05-24

    Binding domain server_name *. abcd.com; Get host name if ($ host ~ * (.*) \ .(.*) \ .(.*)) ( set $ domain $ 1; ) Definition List root html / abc / $ domain /; location / ( root html / abcd / $ domain; index index.html index.php; ) -------------------

  • window appserv secondary domain name how to parse 2011-05-13

    Server configuration: windows2003, appserv-win32-2.5.8.exe Run the program has shopex4.84 file directory: D: \ AppServ \ www wordpress-3.1.2-zh_CN directory: D: \ AppServ \ wordpress The question is: 1. Want to www.xxx.com access shopex 2. Want to ac

  • 5000 yuan to solve the secondary site Custom domain name! 2011-05-12

    Our site uses linux, php, mysql, zendframework framework development, Now need to implement user-defined secondary domain name space with the independent space, have enabled Pan analysis; Companies now realize that the shops http://shopxxxx.jeansworl

  • DNS is the Domain Name System, it is able to 2010-07-31

    DNS is the Domain Name System, it is able to form such a domain name as www.21php.com convert this IP address 211.152.50.35; no DNS, visit the 21php.com this website, you must be so hard to remember 211.152.50.35 number to access. DNS service is prov

  • Apache Rewrite to achieve a URL and domain name jump jump 2011-07-28

    Rewirte main function is to realize the URL of the jump, it is based on Perl regular expression language. Can be based on server-level (httpd.conf) and per-directory (. Htaccess) in two ways. If you want to use the rewrite module, you must first inst

  • . Htaccess redirects top-level domain name space directory binding 2010-02-22

    . Htaccess redirects top-level domain name space directory binding . Htaccess can simply redirect the site to achieve the secondary domain name mentioned. In fact, a simple change it can be redirected to achieve top-level domain name space directory.

  • Rails generated in the two domain 2010-04-23

    Rails in the url_for, the default is a relative address generated by address, of course, you can pass parameters: only_path => false, it can generate complete address. But sometimes we have to specify the two domain names, such as is-programmer.com t

  • DNS Domain Name under Linux 2010-05-29

    1, DNS Services 1. Basic principles DNS (Domain Name System, Domain Name System) is used to name the organization to the domain hierarchy in the computer and network services. DNS name for the Internet and other TCP / IP network, through a user-frien

  • apache server rapid deployment of two domain method 2010-06-23

    First, you must have a top-level domain name; Second, open the httpd.conf mod_rewrite; after modify httpd.conf; Finally, in the root directory of your website / usr / local / www / data-dist, create the corresponding directory. Change vhost.map to ad

  • Sf.net (sourceforge.net) stability of free space to support php, mysql database, binding domain 2010-07-26

    Sf.net (sourceforge.net) stability of free space in the former article, "sf.net / mysql / ssh / sftp stability of the old free space", has introduced into many of his friends also applied for, but not be used for which the data connection, bindi

  • how to config Apache for many domain name 2010-09-16

    ServerAlias: Server alias in Apache can be used to set the virtual host computer is a domain name, you can resolve the domain name for receiving pan. Specific settings as follows: First, to set the virtual host multiple domain names to receive A virt

  • Domain driven design and development of real 2010-09-29

    http://www.infoq.com/cn/articles/ddd-in-practice Background Domain Driven Design (DDD) is central to the concept of how the business is mapped to software artifacts. Most books on the subject and articles to Eric Evans book "Domain Driven Design"

  • Domain analysis, the binding domain, the domain name for the record 2010-09-30

    Can normally use the name of a Web site to access the following two points must be done 1. Domain name has been resolved to your server IP (virtual host is assigned the servers hosting provider IP), and the resolution in force 2. The virtual host has

  • Domain name (domain) 2010-10-15

    Subdomains Definition: Secondary domain name refers to the shape of "bbs.abc.com" the domain name for a sub-domain name top-level domain, characteristic for the domain name consists of two. "." baidu.com is the top-level domain, *. bai

  • Internet domain names of several processing concepts (transfer) 2010-10-21

    VDNS (Visual Domain Name Server) DNS system has all the features, complete visualization, real-time network system allows you to reach every corner of the global network. Features: 1. AB Web Smart synchronization (multiple directories, multiple site

  • Free application and use of domain name space pipni.cz Raiders (MYSQL + PHP + CGI + mail + FTP) 2010-10-27

    Oh, in fact we have always felt very good domain name for free space, then of course, to apply you have to have a own domain name, because the time to register in order to access your domain name, and will not allocate secondary domain name. First, e

  • Hbernate Raiders secondary cache (to) 2010-10-27

    Original address: here. Has been on the hibernate second level cache is not widespread, looking through the articles JE essence, found a lot of good paper. Special turn over. Many people are not very understanding of the secondary cache, or a wrong u