开发者

Add slash at directories, remove slash at files - .htaccess

开发者 https://www.devze.com 2023-02-19 17:03 出处:网络
Ho开发者_开发问答w can I get this to work? I want one single trailing slash at directories, but no slashes at files. So test.php/ becomes test.php and test/folder becomes test/folder/? Now I wrote thi

Ho开发者_开发问答w can I get this to work? I want one single trailing slash at directories, but no slashes at files. So test.php/ becomes test.php and test/folder becomes test/folder/? Now I wrote this code, but that doesn't work:

# Remove trailing slash from files
RewriteCond %{REQUEST_URI} ^/([^/]*)([.]{1})([^./]{1,})/$
RewriteRule . %1.%3 [R=301,L]

# Add trailing slash at directories
RewriteCond %{REQUEST_URI} ^/([^/.]*)$
RewriteRule . %1/ [R=301,L]
0

精彩评论

暂无评论...
验证码 换一张
取 消