Htaccess: add/remove trailing slash from URL

前端 未结 4 1568
时光取名叫无心
时光取名叫无心 2020-11-22 05:36

My website runs a script called -> WSS wallpaper script

My Problem -> I have been trying to force remove or add trailing slash to the end of my URL

4条回答
  •  隐瞒了意图╮
    2020-11-22 06:05

    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /
    ## hide .html extension
    # To externally redirect /dir/foo.html to /dir/foo
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+).html
    RewriteRule ^ %1 [R=301,L]
    
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)/\s
    RewriteRule ^ %1 [R=301,L]
    
    ## To internally redirect /dir/foo to /dir/foo.html
    RewriteCond %{REQUEST_FILENAME}.html -f
    RewriteRule ^([^\.]+)$ $1.html [L]
    
    
    
    order allow,deny
    deny from all
    satisfy all
    
    

    This removes html code or php if you supplement it. Allows you to add trailing slash and it come up as well as the url without the trailing slash all bypassing the 404 code. Plus a little added security.

提交回复
热议问题