2014-09-02 221 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