The principle of subdomain redirection is actually quite simple: users apply for their own subdomains and redirect them to the specified address. For example, applying for **http://anli.iheeo.com** to redirect to **http://www.iheeo.com/post/案例分析.html**. Now let's talk about how this is achieved.
### 1. Implementation Principle
The main technology used here is wildcard domain names (also known as "pan-domain names"). What exactly is a wildcard domain name?
A wildcard domain name looks like ***.iheeo.com**, meaning that any subdomain you use, such as **news.iheeo.com**, **blog.iheeo.com**, or **bbs.iheeo.com**, will all point to the same website hosted on the same server.
The process of setting up a wildcard domain name is also very simple:
- In the DNS settings, create a wildcard domain name called ***.iheeo.com** and point it to the server's IP address.
- On the server, set the host header of the site that uses the wildcard domain name to be blank.
(Here’s an important characteristic of servers: when no matching host header is found in all the site host headers corresponding to the URL, the server will direct traffic to the site without a host header. This is the key to how wildcard domain names work! Because of this feature, other sites can still be placed on the server, but they must have their host headers configured to avoid conflicts.)
In addition, we need to create a page to handle the subdomain redirection. Of course, this page should be set as the homepage.
---
This ensures that when a user accesses a specific subdomain, the server correctly identifies it and redirects the user to the desired target address.