Home  >  Article  >  Backend Development  >  What is the principle of php city sub-station?

What is the principle of php city sub-station?

(*-*)浩
(*-*)浩Original
2019-10-16 10:48:423946browse

Create city sub-stations in the same way as the main station. What is the principle behind the realization of such a function?

What is the principle of php city sub-station?

Locate the city based on IP, create a site management table in the database, associate the site with the city, and add the field site_id (site id) to all data , when you locate the city, you also get the site_id. The site_id stores the cookie, and all the data can be obtained.

The database table should be one, but all the location-related information in it The data will all carry location information. (Recommended learning: PHP video tutorial)

When a user visits 58.com for the first time, judge based on the IP database, and then jump to the corresponding Under the city domain name.

Then add the cookie.

If it is the second time to visit 58.com, jump directly according to the cookie.

Cookie:ipcity=bj|%u5317%u4EAC|0; city=tianshui; 58home=tianshui; commontopbar_city=8601|%u5929%u6C34|tianshui

Laravel's routing, you can In this way

Route::get('/xxx', ['domain' => '{city}.58.com'])

Pass the city as a parameter Go in, and then get whatever data you need. The templates look like the same set.

It doesn’t matter even if the templates are different, you can get the template by city data.

The above is the detailed content of What is the principle of php city sub-station?. For more information, please follow other related articles on the PHP Chinese website!

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