Home >Backend Development >PHP Tutorial >How to create a second-level domain name directly on the backend

How to create a second-level domain name directly on the backend

WBOY
WBOYOriginal
2016-09-11 11:34:111770browse

I recently wrote a personal resume display page. The page to display users is http://xxx.com/?+username. However, I saw that many websites can directly specify a second-level domain name in the background and then bind it. How to achieve this? of?

Reply content:

I recently wrote a personal resume display page. The page to display users is http://xxx.com/?+username. However, I saw that many websites can directly specify a second-level domain name in the background and then bind it. How to achieve this? of?

Some DNS service providers (such as the famous domestic DNSPod) have API interfaces, which can be called to add or delete subdomain names. However, it is more convenient to use pan-domain name resolution.

Pan-wide domain name resolution is to resolve all other domain names (without adding specific records) to one IP.

How to create a second-level domain name directly on the backend

Then in httpd such as nginx, you can also use regular expressions or wildcards to map uncertain domain names to a site.

For example:

<code>server {
    listen 80;
    server_name *.example.com;
    root /path/to/root;
}</code>

Then PHP can identify different domain names through $_SERVER['HTTP_HOST'].

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn