Add Trailing Slash to URLs

后端 未结 2 2055
终归单人心
终归单人心 2020-12-03 16:14

There are quite a few results for add trailing slash .htaccess on Google, but all examples I found require the use of your domain name, as in this example:

R         


        
2条回答
  •  醉酒成梦
    2020-12-03 16:51

    This should work:

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !example.php
    RewriteCond %{REQUEST_URI} !(.*)/$
    RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [L,R=301]
    

提交回复
热议问题