Fix directory and file permissions

These commands recursively fix permissions for directories and files inside a directory in the document root (www).

cd /path/to/directory/inside/www/
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;

Get a list of all “open” directories where any other user can write files.

find . -type d -perm -o=w

Add the following line to your .htaccess to prevent users from browsing your directories.

Options -Indexes

Paul Ryley

Read more posts by this author.

Subscribe to Paul Ryley

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!