开发者

htaccess to prevent root access to folders with no index.htm(l)/php - with a redirect - scripts can still be accessed

开发者 https://www.devze.com 2023-01-15 18:48 出处:网络
What I have in each directory. <Files *> Deny From All </Files> I would like to put an htaccess file in my root main directory that does this:

What I have in each directory.

<Files *>
    Deny From All
</Files>

I would like to put an htaccess file in my root main directory that does this:

1- prevents root access to any folder.

2- Redirects the user to one url should he try to access any root.

3- Still allow scripts to run and write in those dir开发者_如何学Pythonectories publicly.

I also want to make sure that if an index,htm(l)/ or ,php file exists, that is loaded normally.

I seem to be struggling in figuring this out.

Thanks in advance for rewriting this beginner in the right direction.


# 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]    

I’m not sure about your point 3. The webserver doesn’t know if an user agent is a script or a browser.

0

精彩评论

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