1
我正在使用下面的.htaccess文件强制重定向到一个“语言前缀”,如果没有在URL中找到。因此,如果输入domain.com/news,它会重定向到domain.com/en/news - 这很好。.htaccess问题
此规则不应用于某些文件夹,如图像,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]