分城市的分站系统如何建立,求思路
想做一个分站系统,主要是针对不同的城市显示和管理不同的内容。
没有做过,求一个思路,谢谢大家。
比如,我进入北京,这个网上就只显示北京的相关信息。
进上海,就只显示上海的相关信息。
求各位给我一个思路。
回复讨论(解决方案)
用服务器rewrite可以做到
大体思路是这样:通过客户的IP地址获取所在的城市名称,通过城市名称去对应自己网站的分站域名。
一般都有一个IP地址库,这个库可以对应出相应的城市名称,将城市名称对应自己的网站二级域名,在服务器上做好解析。这样就可以了。
比如我的信息街:
北京:beijing.xinxijie.net
上海:shanghai.xinxijie.net
其它未知的就直接解析到www.xinxijie.net
我就是通过这样的方法可以进行对应。
大体思路是这样:通过客户的IP地址获取所在的城市名称,通过城市名称去对应自己网站的分站域名。
一般都有一个IP地址库,这个库可以对应出相应的城市名称,将城市名称对应自己的网站二级域名,在服务器上做好解析。这样就可以了。
比如我的信息街:
北京:beijing.xinxijie.net
上海:shanghai.xinxijie.net
其它未知的就直接解析到www……
有两种情况:
(1)用户直接输入二级域名(2)用户输入的是主站,但是程序要自动跳转到二级域名。像58同城赶集那样
apache服务器支持 二级域名绑定参数,IIS服务器不支持,IIS只支持绑定目录。我以前做过,不过用的方法很笨 ?? IIS绑定目录,然后每个省份都生成一个文件夹,里面写入一个index.php,这个index.php调用的是公用的common.php,然后所有的操作判断都是在这个里面。
最好的办法是从你们公司自己的dns解析去设置,这是效率最高的。如果这个做不到,还可以在你们所有服务器前端做一个反向代理server,比如nginx,它有个扩展模块好像叫geo的模块,可以从这里配置,不同地区的ip段代理到不同的分站。最差的方法就是从程序上判断。三种方式都可以实现。
好吧,最土的方法就是让用户选择地区...嗯 然后读取不同的数据库数据.
好吧,最土的方法就是让用户选择地区...嗯 然后读取不同的数据库数据.
这不叫分站了吧,哈哈。
根据用户的ip自动选取分站的网站,不过还是要通过数据库存取不通的url吧。
最好的办法是从你们公司自己的dns解析去设置,这是效率最高的。如果这个做不到,还可以在你们所有服务器前端做一个反向代理server,比如nginx,它有个扩展模块好像叫geo的模块,可以从这里配置,不同地区的ip段代理到不同的分站。最差的方法就是从程序上判断。三种方式都可以实现。
dnspod有这个功能。
最好的办法是从你们公司自己的dns解析去设置,这是效率最高的。如果这个做不到,还可以在你们所有服务器前端做一个反向代理server,比如nginx,它有个扩展模块好像叫geo的模块,可以从这里配置,不同地区的ip段代理到不同的分站。最差的方法就是从程序上判断。三种方式都可以实现。
其实也算是“云”的概念吧。哈哈哈
一般两个办法:
1、使用rewrite可以做到
2、根据客户的IP地址获取所在的城市,然后通过城市名称去你的库里找对应自己网站的分站域名。
问题的重点不在这儿,我最想知道的是,数据该如何加构,上面各位楼主说的都对,通过IP然后绑定城市域名,那我最想知道的是数据该如何架构,比如我现在进入的是上海站,那就只能看到上海站的相关信息
是不是每个表当中都加一个字段为标志,那这样太麻烦了,每个表当中都要加一个字段来存城市
对,我就是那么控制的,不过城市越多信息量大的时候,会影响速度的。到现在还没有找到更好的思路。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Alipay PHP...

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...
