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]