.htaccess问题

时间:2010-02-03 10:06:22

标签: .htaccess expressionengine

如果在网址中找不到任何内容,我正在使用下面的.htaccess文件强制重定向到“语言前缀”。因此,如果键入domain.com/news,它会重定向到domain.com/en/news - 这样可以正常工作。

此规则不应适用于某些文件夹,例如images,swf和myphp。它适用于前两个,所以当我访问domain.com/swf时,我看到一个目录内容列表,并且没有添加“en”。

但是,它不适用于“myphp”文件夹(这是一个phpmyadmin安装)。通常它会加载myphp / index.php但是将文件名添加到规则没有区别。页面只是继续加载但没有任何反应。有谁知道为什么?

RewriteEngine On
RewriteBase /

#force redirect to language specific page
RewriteCond $1 !^(en|fr|nl)$

#dont apply the rule to the assets folders
RewriteCond $1 !^images$
RewriteCond $1 !^swf$
RewriteCond $1 !^myphp$

#redirect to default EN page if no language param is present in URI
RewriteRule ^([^/]+)/.* /en/$0 [L,R=301]

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

1 个答案:

答案 0 :(得分:1)

在我看来,由于尝试匹配文件夹名称后面的行尾($),当网址中有更多内容时,您可能会遇到问题。如果您将美元符号从文件夹名称中删除会怎样?