2010-02-03 34 views
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] 

回答

1

在我看來,你可能遇到了問題,由於試圖在文件夾名後的線($)結束時,匹配有更多的URL。如果您將美元符號從文件夾名稱中刪除,會發生什麼情況?