.htaccess - Hiding a directory in the URL while preserving other files

前端 未结 2 744
温柔的废话
温柔的废话 2021-01-22 08:22

I developed a giant studio of tools and each tool has its own directory in the /tools/ folder. So if you have a tool named example, the URL would be /studio-dir/tools/e

2条回答
  •  滥情空心
    2021-01-22 08:58

    In this example there is not 404 but it only works to hide only one dir

    RewriteEngine On
    RewriteBase /
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+dirname/([^\s]+) [NC]
    RewriteRule ^ %1 [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule (?!^dirname/)^(.*)$ /dirname/$1 [L,NC]
    

提交回复
热议问题