htaccess防止root访问没有index.htm(l)/ php的文件夹 - 使用重定向 - 仍然可以访问脚本

Jim*_*_Bo 1 .htaccess

我在每个目录中有什么.

<Files *>
    Deny From All
</Files>
Run Code Online (Sandbox Code Playgroud)

我想在我的根主目录中放置一个htaccess文件来执行此操作:

1-防止root访问任何文件夹.

2-如果用户尝试访问任何根,则将用户重定向到一个URL.

3-仍然允许脚本公开运行和写入这些目录.

我还想确保如果存在正常加载的索引htm(l)/或php文件.

我似乎在努力搞清楚这一点.

提前感谢您以正确的方向重写这位初学者.

fux*_*xia 6

# No root access without index.*
Options -Indexes
DirectoryIndex index.php index.html index.htm

# Rewrite
RewriteEngine On
RewriteBase /

# Existing file
RewriteCond %{REQUEST_FILENAME} !-f
# Existing directory
RewriteCond %{REQUEST_FILENAME} !-d
# Symbolic link
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^ your-default-file.html [L]    
Run Code Online (Sandbox Code Playgroud)

我不确定你的观点3.网络服务器不知道用户代理是脚本还是浏览器.