Useful commands for . Htacess

Asked

Viewed 357 times

0

I would like to know some commands to use in . htacess that allow to do the following actions.

1- Block access to all directories so that if the user tries to see the contents of this directory is barred with a warning or redirect to a page.

2- Block downloading files . php, . js, . css, . html and images.

3 - open a file that is not index.php as index page

If possible if you could give me other useful commands that would help me a lot.

  • 1

    Do this with the htaccess would make your site useless, as image, css and js files are downloaded to the user’s computer along with HTML so that they can view your site. For this you would need to handle all requests in PHP, including js, css, img, etc...

1 answer

1

1 - Preventing directory listing:

Options -Indexes

2 - the server itself prevents the download of PHP, but js, css and html run on the client side, if it prevents its download, no one will see your site.

3 - To set the default home pages use:

DirectoryIndex index.html index.php index.html

for example to define company.html:

DirectoryIndex empresa.html

Browser other questions tagged

You are not signed in. Login or sign up in order to post.