5

Should I include a index.php with //silence is golden to every folder in my plugin? even css, js and images folders? Or is it just folders that contain code/ php files that should have the index.php file in it?

Herr Kingsley
  • 128
  • 1
  • 7

1 Answers1

8

This article from InMotion explains why such file exists: Silence is Golden.

Quoting here the relevant parts in case the link goes down in the future:

The entire file is a placeholder. Whenever someone visits a web page, the server attempts to run index.php or index.html. If you take a look at your site directory’s index.php, you’ll see the code that generates a WordPress site.

Without index.php, anyone could just visit your site’s /wp-content folder and see all of the media, files, and directories it contains.

The index.php file functions like a privacy screen: it blocks visitors from directly accessing your directories.

Or you can use below code in your .htaccess file to prevent directory listings even if that index.php file is not present:

Options –Indexes
cabrerahector
  • 3,653
  • 4
  • 16
  • 27
  • In the article it says "Without index.php, anyone could just visit your site’s /wp-content folder and see all of the media, files, and directories it contains." So basically every folder you don't want people to be able to see the content of...right? – Herr Kingsley May 14 '21 at 11:28
  • 1
    Correct, @HerrKingsley. – cabrerahector May 14 '21 at 12:47
  • 3
    Manish, please avoid link-only answers. The URL might be removed in the future and people won't be able to read the solution to the problem. I edited your question to include the relevant parts of the referenced article so your answer remains useful even if the InMotion website were to dissapear. – cabrerahector May 14 '21 at 12:55
  • @cabrerahector Noted Thank you – MANISH KANVADIYA May 14 '21 at 19:01