想做一个分站系统,主要是针对不同的城市显示和管理不同的内容。
没有做过,求一个思路,谢谢大家。
比如,我进入北京,这个网上就只显示北京的相关信息。
进上海,就只显示上海的相关信息。
求各位给我一个思路。
回复讨论(解决方案)
用服务器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然后绑定城市域名,那我最想知道的是数据该如何架构,比如我现在进入的是上海站,那就只能看到上海站的相关信息
是不是每个表当中都加一个字段为标志,那这样太麻烦了,每个表当中都要加一个字段来存城市
对,我就是那么控制的,不过城市越多信息量大的时候,会影响速度的。到现在还没有找到更好的思路。

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


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

Dreamweaver CS6
Visual web development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Zend Studio 13.0.1
Powerful PHP integrated development environment

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool