12
<?php
// Silence is golden.

The folder is ../wp-content/index.php

Why have this file. What's the purpose?

I suppose it's in order to avoid invalid visit.

But why?

0

2 Answers 2

25

Try to visit through the folder structure of your site from the browser:

http://example.com/wp-content/

You will see a blank page. That's actually is the index.php, and its content is very simple - a commented out PHP comment:

<?php
// Silence is golden.

Remove the file and visit the URL again. You will see the file structure completely. So your file structure is completely become naked.

That's why the file is there. To hide the inner file structure whatever that be.

O, don't forget to create the file again there. :)

0
7

This file is just there if the server (Apache, Nginx, Lighttp, etc.) is not properly set up and allowing this kind of file system access for guests. To properly set up your Apache for e.g., just add the following to your .htaccess

Options –Indexes

which will lead to a Forbidden|403 for everyone trying to access your directory structure (prevents directory listings). There is a more detailed explanation as well.

The Options directive is the place where you can enable or disable the index generation. This is set by default to ALL (meaning that it will turn ON also Indexes), but normally you will see this overwritten by each distribution either globally or inside the default vhost definition.

Not the answer you're looking for? Browse other questions tagged or ask your own question.