2012-01-02 113 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] 
相关问题