与mod_GeoIP htaccess的重写规则 [英] htaccess rewrite rules with mod_GeoIP

查看:142
本文介绍了与mod_GeoIP htaccess的重写规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用mod_geoip一些问题,一个电子商务网站,拥有3个不同的商店。我们有我们的根/店总店,而且还具备有存储在根/ ukstore和根/ austore。主根/存储包含一个/皮肤,/包含所有的CSS,图像和Javascript角媒体,和/ JS目录。有了这个当前的设置,网址完美换出的基地,但保留URL的其余部分完好的,所以如果一个来自英国的用户进入根/存储/分类/产品/他们重定向到root / ukstore /分类/产品/ 。

I'm having some issues with mod_geoip for an ecommerce site that has 3 different stores. We have our main store at root/store, but also have have stores at root/ukstore and root/austore. The main root/store contains a /skin, /media, and /js directories that contain all css, images, and javascripts. With this current setup, the urls flawlessly swap out the base, but leaves the rest of the URL intact so if a user from the UK goes to root/store/category/product/ they get redirected to root/ukstore/category/product/.

2的东西都是问题吧。

2 things that are issues now.

每当有客户访问像结账或帐号,javascript中被改写为根/ ukstore /皮肤或根/ ukstore / JS对CSS的URL和一个安全的页面。是否有什么我的问候失踪SSL为这些网址?

Whenever a customer accesses a secure page like checkout or account, the URLs for css and javascript are being rewritten to root/ukstore/skin or root/ukstore/js. Is there something I'm missing in regards to SSL for those URLs?

其次,如果从南非用户访问商店,它们被改写为英国存储和所有的CSS,JS,图像被完全链接回商店/皮肤,但如果从英国用户访问存储那么对于CSS,JS和图像的URL正试图改写为根/ ukstore /皮肤

Secondly, if a user from South Africa accesses the store, they are rewritten to the UK store and all the css, js, images are perfectly linked back to store/skin, but if a user from the United Kingdom accesses the store then the URLs for css, js, and images are trying to be rewritten to root/ukstore/skin

下面是code在根/存储我的htaccess文件。每家商店也有自己的htaccess的文件,但没有太多的在那里。

Here is the code in my htaccess file in root/store. Each store also has their own htaccess file, but without much in there.

<IfModule mod_geoip.c>
GeoIPEnable On

Options +FollowSymLinks
RewriteEngine on
#skip processing directories
RewriteRule ^store/skin/  - [L,NC]
RewriteRule ^store/media/  - [L,NC]
RewriteRule ^store/js/  - [L,NC]

RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(AQ|AU|MY|BV|BN|BN|MM|KH|CN|CX|CC|CK|GQ|FJ|PF|GU|GW|HM|HK|ID|KI|KR|KP|KR|LA|MO|MY|MH|FM|MM|NR|NC|PG|NZ|NU|NF|PG|CN|PH|PN|WS|SG|SB|KR|LK|BN|TW|TW|AU|TH|TL|TK|TO|TV|VU|VN|VN|WF)$
RewriteCond %{REQUEST_URI} ^/store(/.*)$ [NC]
RewriteRule ^ /austore%1 [L,R]

#UK Store Rewrites
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(AF|AX|AL|DZ|AD|AO|AM|AT|AZ|BH|BD|IS|BY|BE|BJ|BT|BA|BW|IO|BG|BF|BI|GB|CM|ES|CV|CF|TD|GB|KM|CG|CD|CG|CD|CI|HR|CY|CZ|CZ|BJ|DK|DJ|EG|ER|EE|ET|FO|FI|FR|TF|GA|GM|GE|DE|GH|GI|GD|GR|GL|GN|VA|HU|IS|IN|IR|IR|IQ|IE|IL|IT|CI|JO|KZ|KE|KW|KG|LV|LB|LS|LR|LY|LY|LI|LT|LU|MK|MG|MW|MV|ML|MT|MR|MU|MC|MC|MN|ME|MA|MZ|NA|NP|NL|NE|NG|IE|NO|OM|PK|PS|PS|CG|PL|PT|QA|CI|MK|ZA|CD|RE|RO|RU|RW|SH|SM|ST|SA|SN|RS|SC|SL|SK|SI|SO|SO|ZA|ES|SD|SJ|SZ|SE|CH|SY|SY|TJ|TZ|TN|TR|TM|AE|UG|UA|AE|GB|BF|UZ|VA|GB|EH|YE|ZM|ZW)$
RewriteCond %{REQUEST_URI} ^/store(/.*)$ [NC]
RewriteRule ^ /ukstore%1 [L,R]
</IfModule>

任何帮助将是很大的AP preciated!

Any help would be greatly appreciated!

推荐答案

现在的问题是,你正在使用的重写条件中的.htaccess上下文等等条件应该是相对于你所在的目录,这就是为什么重写条件相对于皮肤,在问题中提到js和媒体的不匹配。你应该像他们替换:

The problem is that you are using the rewrite conditions in a .htaccess context so the conditions should be relative to the directory you are in and that is the reason why the rewrite conditions relative to the skin, js and media mentioned in the question do not match. You should replace them with something like:

RewriteRule ^(skin|media|js)/ - [L,NC]

或,正如mod_rewrite的导向(的http:// httpd的.apache.org /文档/电流/ MOD / mod_rewrite.html#重写规则

如果你想匹配的完整URL路径中每个目录   在(htaccess的)重写规则,使用%{REQUEST_URI}变量   RewriteCond指令。

If you wish to match against the full URL-path in a per-directory (htaccess) RewriteRule, use the %{REQUEST_URI} variable in a RewriteCond.

这篇关于与mod_GeoIP htaccess的重写规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆