我正在尝试找出一种方法来执行以下操作:
将“lang token”包含到所有 .htaccess 重写网址中,如下所示:
RewriteRule ^/?$ _main_htaccess_handler?mod=homepage&lang=[LANG_STRING]
RewriteRule ^disclaimer\.htm?$ _main_htaccess_handler?mod=disclaimer&lang=[LANG_STRING]
...等等,对于所有网址
除意大利之外的所有国家/地区:
[LANG_STRING] = 'EN';
国家/地区意大利
[LANG_STRING] = 'IT';
现在,在寻找实现此目的的方法时,我找到了以下脚本:
http: //ipinfodb.com/country_query.php?country=IT&output=htaccess_allow
这将输出分配给某个国家/地区的 IP 列表,准确度为 99.5%。
我想将这些 IP 子网字符串“链接”到上面提到的 .htaccess 类型的方法。
不管怎样,我对在没有 mod_geoip 的情况下通过 .htaccess 进行地理定位有点困惑。
您认为我“创建”并上面提到的解决方案可以很好地工作吗?那么,搜索引擎呢?例如,Google Italy 能否正确找到意大利语页面? (这个问题适用于所有搜索引擎)
非常感谢
I'm trying to figure out a method to do the following:
Include a "lang token" into ALL .htaccess rewrited-urls, like this:
RewriteRule ^/?$ _main_htaccess_handler?mod=homepage&lang=[LANG_STRING]
RewriteRule ^disclaimer\.htm?$ _main_htaccess_handler?mod=disclaimer&lang=[LANG_STRING]
... and so on, for all the urls
All countries EXCEPT Italy:
[LANG_STRING] = 'EN';
Country ITALY
[LANG_STRING] = 'IT';
Now, searching for a method to accomplish this, I've found this script:
http://ipinfodb.com/country_query.php?country=IT&output=htaccess_allow
This will output a list of IPs allocated to a country, with a 99.5% accuracy.
I would like to "link" those IP subnet strings to the .htaccess type of approach mentioned above.
Anyway, I'm a little bit confused about geolocalization via .htaccess without the mod_geoip.
Do you think the solution I've "created" and mentioned above can work good? And then, what about search engines? Will, for example, Google Italy correctly find pages in Italian? (this question applies to all search engines)
Thank you very much
发布评论
评论(3)
拥有巨大的 .htaccess 文件从来都不是一个好主意,因为在每次向给定网站发出请求之前都会解析该文件,从而导致性能损失。
Having a huge .htaccess file is never a good idea, since the file is parsed before every request to the given website, resulting in loss of performance.
在尝试了一些技术之后,我选择了一种混合技术:PHP + htaccess
我正在为那些将要解决这个问题的人编写它。
HTACCESS 配置:
_builder.php 代码(相对于意大利语和英语,可轻松转换以满足您的需求)
最后,可以通过 Google“PHP geoplugin”或以下网址访问 geoPlugin 类:
http://www.geoplugin.com/webservices/php
请记住将语言设置器片段放入您的主构建器,因此脚本可以知道在页面上输出什么语言,即使 htaccess 没有传递该语言。
After having tried some techniques, I've opted for an hybrid one: PHP + htaccess
I'm writing it for the ones that will fly into this question.
HTACCESS CONFIGURATION:
_builder.php CODE ( relative to Italian and English Language, easily convertible to suit your needs )
Finally, the geoPlugin Class is reachable through Google "PHP geoplugin" or by this url:
http://www.geoplugin.com/webservices/php
Remember to place the language setter snippet into your main builder, so the script can know what language to output on the page, even if that wasn't passed by htaccess.
我尝试获取美国 IP htaccsses 代码
code
Site1 senior188
Site2 senior188
Site3 senior188
site4 senior188
它正在工作,页面转到 403 ..但是我尝试用另一个IP国家/地区打开页面仍然显示403..它应该只适用于美国IP..
i try for the US IP htaccsses code
code
Site1 senior188
Site2 senior188
Site3 senior188
site4 senior188
it's working the page go to 403.. but i try open with another IP country the page still showed 403.. it should only for US IP..