2014-12-07 35 views
0

我使用當前的代碼刪除從我的網址.shtml我的一個項目中刪除擴展:的.htaccess從URL結尾/文件夾

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^/]+)/$ $1.shtml 
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.shtml 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$ 
RewriteRule (.*)$ /$1/ [R=301,L] 

它可以正常使用等我把一個以上的子文件夾,如/folder1/folder2/,那麼它無法找到文件夾2參數。我甚至不知道從哪裏何去何從,使其工作(我沒有太多的經驗,在使用.htaccess

回答

0

爲什麼不直接替換這兩行:

RewriteRule ^([^/]+)/$ $1.shtml 
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.shtml 

RewriteCond %{DOCUMENT_ROOT}/$1.shtml -f 
RewriteRule ^(.*)/$ /$1.shtml [L]