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/.
对于有3个不同商店的电子商务网站,我遇到了mod_geoip的一些问题。我们在root / store有我们的主店,但在root / ukstore和root / austore也有商店。主根/存储包含/ skin,/ media和/ js目录,其中包含所有css,images和javascripts。通过这个当前设置,网址完美地交换了基础,但保留了URL的其余部分,因此如果来自英国的用户转到root / store / category / product /,它们将被重定向到root / ukstore / category / product / 。
2 things that are issues now.
现在有两件事是问题。
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和javascript的URL都会被重写为root / ukstore / skin或root / ukstore / js。对于那些URL,我是否缺少SSL的问题?
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
其次,如果来自南非的用户访问商店,则将它们重写到英国商店,并且所有css,js,图像完美地链接回商店/皮肤,但如果来自英国的用户访问商店,则URL因为css,js和images正在尝试重写为root / ukstore / skin
Here is the code in my htaccess file in root/store. Each store also has their own htaccess file, but without much in there.
这是我的htaccess文件在root / store中的代码。每个商店也有自己的htaccess文件,但没有太多。
<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>
Any help would be greatly appreciated!
任何帮助将不胜感激!
2 个解决方案
#1
1
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:
问题是您在.htaccess上下文中使用重写条件,因此条件应该相对于您所在的目录,这就是为什么相对于问题中提到的皮肤,js和媒体的重写条件不相关的原因比赛。您应该用以下内容替换它们:
RewriteRule ^(skin|media|js)/ - [L,NC]
or, as mentioned in the mod_rewrite guide ( http://httpd.apache.org/docs/current/mod/mod_rewrite.html#RewriteRule )
或者,如mod_rewrite指南中所述(http://httpd.apache.org/docs/current/mod/mod_rewrite.html#RewriteRule)
If you wish to match against the full URL-path in a per-directory (htaccess) RewriteRule, use the %{REQUEST_URI} variable in a RewriteCond.
如果您希望匹配每个目录(htaccess)RewriteRule中的完整URL路径,请在RewriteCond中使用%{REQUEST_URI}变量。
#2
0
Ip-based redirection could fail and what usually people want is language-based redirection. You can read the language configured in the user browser and just redirect them to a language that your web has. Just like that:
基于Ip的重定向可能会失败,通常人们想要的是基于语言的重定向。您可以阅读用户浏览器中配置的语言,只需将其重定向到您的网站所使用的语言即可。就像那样:
RewriteCond %{HTTP:Accept-Language} ^(en|ja|de|zh|fr|it|nl|fi|sv|no) [NC]
RewriteRule ^$ /en [R=303,L,QSA]
And what you want in your approach is to have a direct access to the static files in your server, this can be achieved setting this condition, so static files don't get rewrited
你想要的方法是直接访问服务器中的静态文件,这可以通过设置这个条件来实现,所以静态文件不会被重写
RewriteCond %{REQUEST_FILENAME} !-f
#1
1
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:
问题是您在.htaccess上下文中使用重写条件,因此条件应该相对于您所在的目录,这就是为什么相对于问题中提到的皮肤,js和媒体的重写条件不相关的原因比赛。您应该用以下内容替换它们:
RewriteRule ^(skin|media|js)/ - [L,NC]
or, as mentioned in the mod_rewrite guide ( http://httpd.apache.org/docs/current/mod/mod_rewrite.html#RewriteRule )
或者,如mod_rewrite指南中所述(http://httpd.apache.org/docs/current/mod/mod_rewrite.html#RewriteRule)
If you wish to match against the full URL-path in a per-directory (htaccess) RewriteRule, use the %{REQUEST_URI} variable in a RewriteCond.
如果您希望匹配每个目录(htaccess)RewriteRule中的完整URL路径,请在RewriteCond中使用%{REQUEST_URI}变量。
#2
0
Ip-based redirection could fail and what usually people want is language-based redirection. You can read the language configured in the user browser and just redirect them to a language that your web has. Just like that:
基于Ip的重定向可能会失败,通常人们想要的是基于语言的重定向。您可以阅读用户浏览器中配置的语言,只需将其重定向到您的网站所使用的语言即可。就像那样:
RewriteCond %{HTTP:Accept-Language} ^(en|ja|de|zh|fr|it|nl|fi|sv|no) [NC]
RewriteRule ^$ /en [R=303,L,QSA]
And what you want in your approach is to have a direct access to the static files in your server, this can be achieved setting this condition, so static files don't get rewrited
你想要的方法是直接访问服务器中的静态文件,这可以通过设置这个条件来实现,所以静态文件不会被重写
RewriteCond %{REQUEST_FILENAME} !-f