重定向到子域
我希望你可以帮助我。
我需要将流量定向到某些子域。 EG
我住在 RSA,我们有 4 个主要城市。
开普敦 约翰内斯堡 东开普省 德班
我有以下子域名
capetown.mydomain.co.za 约翰内斯堡.mydomain.co.za 德班.mydomain.co.za eastcape.mydomain.co.za
现在,当有人从开普敦打开我的网站时,他们必须转到子域 capetown.mydomain.co.za ,反之亦然。
口香糖树可以做到!
如果您能提供帮助,将不胜感激。
问候 马修
I hope you can help me.
I need to direct traffic to certian subdomains. EG
I live in RSA and we have 4 major cities.
Cape Town
Johannesburg
Eastern Cape
Durban
I have the following sub domainds
capetown.mydomain.co.za
johannesburg.mydomain.co.za
durban.mydomain.co.za
easterncape.mydomain.co.za
Now when some one opens my website from cape town, they must goto subdomain capetown.mydomain.co.za and vise versa.
Gum tree does it !
If you can help, it would be greatly appriated.
REgards
Matthew
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要根据 IP 位置数据库检查访问者的 IP 地址。 快速谷歌一下就找到了这个:http://www.maxmind.com/app/csharp
然后您只需将请求重定向到正确的子域即可。
You'll need to check the Ip adress of the visitor against an ip-location database. A quick google turned up this one: http://www.maxmind.com/app/csharp
Then you just redirect the request to the correct subdomain.
您需要订阅包含城市级别详细信息的 GeoIP 服务。
在您的主页中,您将有一个脚本,该脚本向 GeoIP 服务提供 IP 地址,然后根据返回的城市详细信息进行重定向。
You will need to subscribe to a GeoIP service that has detail down to the city level.
In your main page you would have a script that supplies the IP address to the GeoIP service and then do a redirect based on the city details returned.
Maxmind 地理定位服务对于这项工作非常有用。 Geolite 免费数据库仅适用于国家分辨率,因此您需要订阅该服务才能获得更准确的信息来获取城市。
另一个IP位置数据库提供商:
http://www.ip2country.net/
Maxmind geolocation service can be very useful for the job. The Geolite free database only works with countries resolution, so you need to suscribe to the service in order to have more accurate information to obtain cities too.
Another IP location database provider:
http://www.ip2country.net/