Home >Backend Development >PHP Tutorial >How to let users add a second-level domain name and then direct this second-level domain name to their own website? Use nginx+tp

How to let users add a second-level domain name and then direct this second-level domain name to their own website? Use nginx+tp

WBOY
WBOYOriginal
2016-10-11 14:23:371600browse

For example, our main website is test.com

Users can customize a second-level domain name of myweb.test.com on our website, and then transfer this domain name to his own website abc.com, and the website address has not changed, it is still myweb.test.com

Somewhat similar to Taobao’s merchant-customized domain name

What is the general idea? Does nginx need to configure anything?

Reply content:

For example, our main website is test.com

Users can customize a second-level domain name of myweb.test.com on our website, and then transfer this domain name to his own website abc.com, and the website address has not changed, it is still myweb.test.com

Somewhat similar to Taobao’s merchant-customized domain name

What is the general idea? Does nginx need to configure anything?

This requires domain name resolution

  1. test.com/myweb

    => abc.com This is easier to implement. You can directly rewrite the URL to xxx.php, parse the path and then redirect it.

  2. myweb.test.com

    => abc.com If there are few websites, you can directly configure redirection in nginx, but if the subdomain name needs to be dynamically redirected to the specified domain name, it feels like Not easy to implement.

First make sure whether your domain name service provider supports pan-resolution. If so, go to the second step

Make a corresponding relationship, which can be placed in the sharedict of ngx_lua, and then redirect. Of course, if you need a small amount, just write it directly into the configuration

But that’s it Come on, aren't you afraid that users will redirect you to a place full of short movies?

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