2012-01-02 112 views
1

我的webroot中有一個名爲Country的文件夾。我在這個子文件夾中有一個index.html頁面。如果我輸入domain.com/country,則會獲得domain.com/app/webroot/country/。 如果我在國家後面輸入「/」,我會得到我需要的domain.com/country/。我如何使用htaccess從domain.com/country重定向到domain.com/country/htaccess從子文件夾中的索引頁面重定向到子文件夾

我希望規則只適用於國家/地區文件夾。我有以下規則,但它適用於我不想要的整個站點。

RewriteEngine on 
# index.php to/
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/ 
RewriteRule ^(.*)index\.php$ /$1 [R=301,L] 

任何幫助將不勝感激。

回答

0

嘗試添加以下到您的域的根文件夾.htaccess文件,領先其他任何規則,你有

RewriteEngine on 
RewriteBase/

#if country does not have a trailing slash 
RewriteCond %{REQUEST_URI} ^/country$ [NC] 
#redirect to country with a trailing slash 
RewriteRule . /country/ [L,R=301] 
相關問題