2014-09-02 225 views
0

我有以下htaccess: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^.*$ index.php [QSA,NC,L] 和一切工作正常。但現在我需要從URL中刪除尾部斜槓。這意味着http://localhost:8888/folder_app/en/psssses/index/asd/(注意後面的斜線)將重定向到http://localhost:8888/folder_app/en/psssses/index/asd沒有斜線... 求助htaccess刪除尾部斜槓

回答

1

您可以使用這個新的規則非常感謝:

RewriteEngine On 
RewriteBase /folder_app/ 

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{THE_REQUEST} /(.+?)/+[?\s] 
RewriteRule ^(.+?)/$ $1 [R=301,L,NE] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . index.php [L] 
+0

謝謝,這個工作,但不像我預料的那樣。我的應用程序位於文件夾folder_app中,因此url爲'http:// localhost:8888/folder_app',並且您的代碼重定向到根http:// localhost:8888 /'..您知道如何重定向到當前文件夾嗎?謝謝 – user3347718 2014-09-03 19:48:57

+0

好吧現在嘗試更新的代碼 – anubhava 2014-09-03 19:52:45