2013-05-03 43 views
-1

最近,我的托管服务提供商已将其apache系统更新为2.4.4。在这样做,它已经导致我的表达引擎网站中断,因为我现在需要强制查询字符串来运行网站。弃用PATH_INFO .htaccess规则损坏

从我了解你可以很容易地通过刚刚更新线在我的.htaccess规则来解决这个问题...

RewriteRule ^(.*)$ /index.php?/$1 [L] 

不幸的是,这种修复并不这么简单。

我的网站使用自定义表达引擎插件来检测他们在使用IP到Nation模块的世界的哪个区域。基本上发生的事情是,如果你来自美国,你会看到美国内容为&的网站,如果你从其他任何地方将“国际”附加到URI的第一部分,该部分将根据第一部分显示国际内容我们的URI

例如

http://www.example.com/segment_1/segment_2/segment_2 = US SITE 

http://www.example.com/international/segment_1/segment_2/segment_2 = INTERNATIONAL SITE 

当我试图在查询字符串添加到重写规则进行的index.php它打破了国际网站,我不知道为什么。

RewriteCond $1 !\.(gif|jpe?g|png)$ [NC] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php/$1 [L] 
RewriteRule /international/(.*)$ /index.php/$1 [L] 

添加“?”到RewriteRule ^(.*)$ /index.php?/$1 [L]修复美国网站,但打破国际网站,说它无法找到国际页面。

添加“?”到RewriteRule /international/(.*)$ /index.php?/$1 [L]修复国际网站,但美国网站将无法正常工作,因为它需要查询字符串。

并将它添加到他们都不会工作。

我很明显错过了.htaccess中的某些内容来克服这个问题,但我似乎无法生成正确的语法。

任何想法?

回答

1

我要在这里乘坐胡乱猜测,因此可能会完全无用......

RewriteCond $1 !\.(gif|jpe?g|png)$ [NC] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php/$1 [L] 
RewriteRule /international/(.*)$ /index.php/$1 [L] 

问题看起来你重写URL中的index.php添加?然后将其添加在再次为国际 - 因此,当你添加“?”它既杀死了重写。

因此,第一次重写你需要排除国际,第二次确保它只是影响国际。

RewriteCond $1 !\.(gif|jpe?g|png)$ [NC] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !(international) 
RewriteRule ^(.*)$ /index.php?/$1 [L] 
RewriteCond %{REQUEST_URI} (international) 
RewriteRule /international/(.*)$ /index.php?/$1 [L] 

您可能需要重复第二部分的3个初始条件。

UPDATE

这得到它到底工作(感谢您指出我在正确的方向 - 卢克)

RewriteCond $1 !\.(gif|jpe?g|png)$ [NC] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !(international) 
RewriteRule ^(.*)$ /index.php?/$1 [L] 

RewriteCond $1 !\.(gif|jpe?g|png)$ [NC] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} (international) 
RewriteRule ^(.*)$ /index.php/$1 [L] 
RewriteRule /international/(.*)$ /index.php?/$1 [L] 
+0

这almpost工作,这definetly指着我towrads正确的方向谢谢非常。我只需要添加'RewriteRule ^(。*)$ /index.php/$1 [L]'就好像国际因为索引而已。PHP仍然需要可用+我确实需要重复3个初始条件以及第二部分。谢谢@彼得刘易斯 – 2013-05-03 13:53:39