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
Release: 2016-09-11 11:34:11
Original
1767 people have browsed it

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>
Copy after login

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

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template