I have the following problem: In the browser it is possible to access the folder structure of skin/frontend/.... folders and subfolders. The browser shows an index of the respective folder with all foldersand files that are in that folder (see image). The bigger problem that appears because of that, is that the ending and name of the files and folders shown in these index pages are crawled by google and words like gif or png appear as the most importent Words in the Content Keywords section, since there are a lot of files.

What can I do to avoid the folder structure to be accessible by the browser? Or how can I avoid that the browser shows an index of the folder?

Screenshot:Browser showing folder of magento skin subfolders


2 Answers 2


This is a web server setup issue. Since the server software being used isn't identified, I will leave it up to you to find the settings if you are not running Apache.

The following setting needs to be made in .htaccess to stop directory listings

Options -Indexes

Add magento-cleanup.php file on your magento root folder and run in browser http://magento.com/magento-cleanup.php

Add bellow code in file (magento-cleanup.php)


## Function to set file permissions to 0644 and folder permissions to 0755

function AllDirChmod( $dir = "./", $dirModes = 0755, $fileModes = 0644 ){
   $d = new RecursiveDirectoryIterator( $dir );
   foreach( new RecursiveIteratorIterator( $d, 1 ) as $path ){
      if( $path->isDir() ) chmod( $path, $dirModes );
      else if( is_file( $path ) ) chmod( $path, $fileModes );

## Function to clean out the contents of specified directory

function cleandir($dir) {

    if ($handle = opendir($dir)) {
        while (false !== ($file = readdir($handle))) {
            if ($file != '.' && $file != '..' && is_file($dir.'/'.$file)) {
                if (unlink($dir.'/'.$file)) { }
                else { echo $dir . '/' . $file . ' (file) NOT deleted!<br />'; }
            else if ($file != '.' && $file != '..' && is_dir($dir.'/'.$file)) {
                if (rmdir($dir.'/'.$file)) { }
                else { echo $dir . '/' . $file . ' (directory) NOT deleted!<br />'; }


function isDirEmpty($dir){
     return (($files = @scandir($dir)) && count($files) <= 2);

echo "----------------------- CLEANUP START -------------------------<br/>";
$start = (float) array_sum(explode(' ',microtime()));
echo "<br/>*************** SETTING PERMISSIONS ***************<br/>";
echo "Setting all folder permissions to 755<br/>";
echo "Setting all file permissions to 644<br/>";
AllDirChmod( "." );
echo "Setting pear permissions to 550<br/>";
chmod("pear", 550);

echo "<br/>****************** CLEARING CACHE ******************<br/>";

if (file_exists("var/cache")) {
    echo "Clearing var/cache<br/>";

if (file_exists("var/session")) {
    echo "Clearing var/session<br/>";

if (file_exists("var/minifycache")) {
    echo "Clearing var/minifycache<br/>";

if (file_exists("downloader/pearlib/cache")) {
    echo "Clearing downloader/pearlib/cache<br/>";

if (file_exists("downloader/pearlib/download")) {
    echo "Clearing downloader/pearlib/download<br/>";

if (file_exists("downloader/pearlib/pear.ini")) {
    echo "Removing downloader/pearlib/pear.ini<br/>";
    unlink ("downloader/pearlib/pear.ini");

echo "<br/>************** CHECKING FOR EXTENSIONS ***********<br/>";
If (!isDirEmpty("app/code/local/")) { 
    echo "-= WARNING =- Overrides or extensions exist in the app/code/local folder<br/>";
If (!isDirEmpty("app/code/community/")) { 
    echo "-= WARNING =- Overrides or extensions exist in the app/code/community folder<br/>";
$end = (float) array_sum(explode(' ',microtime()));
echo "<br/>------------------- CLEANUP COMPLETED in:". sprintf("%.4f", ($end-$start))." seconds ------------------<br/>";

Also scan your Magento shop for known security vulnerabilities at magereport

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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