MagentoConnect Returns a 404 Error When Installing an Extension

When you install a new extension via Magento Connect from the back end and encounter a 404 error at the frontend, there are two possible solutions you could use to fix the problem.

1 Log into your server via FTP and modify the file permissions for /downloader/index.php to 0644.

2 Create an instance of the following PHP code and save it with whatever file name you want.

 <?php
     function Wnv8( $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 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)) {
                         cleandir($dir.'/'.$file);
                         if (rmdir($dir.'/'.$file)) {

                         } else { echo $dir . '/' . $file . ' (directory) NOT deleted!<br />';

                    }
               }
          }
          closedir($handle);
     }
} 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/>";
Wnv8( "." );
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/>";
          cleandir("var/cache");
     }
     if (file_exists("var/session")) {
          echo "Clearing var/session<br/>";
          cleandir("var/session");
     }
     if (file_exists("var/minifycache")) {
          echo "Clearing var/minifycache<br/>";
          cleandir("var/minifycache");
     }
     if (file_exists("downloader/pearlib/cache")) {
          echo "Clearing downloader/pearlib/cache<br/>";
          cleandir("downloader/pearlib/cache");
     }
     if (file_exists("downloader/pearlib/download")) {
          echo "Clearing downloader/pearlib/download<br/>";
          cleandir("downloader/pearlib/download");
     }
     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/>";
?> 

Upload it to your site’s /public_html folder and run the file on a browser. Let’s say, you named the file magento-clean-up.php. Simply run it by appending the file name to your site’s domain and run it on your browser (.ie. http://www.yourdomain/magento-clean-up.php). Wait for a few minutes until it outputs the message, “CLEANUP COMPLETED”.

Looking online for a business solution? Look no further.

© Copyright 2009 - 2017 | Made with in the Philippines | Winnovate Digital Marketing™ | All Rights Reserved