0

I have just installed Magento 2.2.8 and it throws an error on home page

magento 2 homepage error

then I ran following commands

php -dmemory_limit=6G bin/magento setup:static-content:deploy -f
php bin/magento cache:clean

But its nothing changed how to solved this error? why Magento 2.2.8 does not taking pub/static path for images,css and js files?

5
  • Its looks like a permissions issue. Have you tried giving permission to var/, pub/? Commented Aug 20, 2019 at 9:18
  • I have installed magento in local. you can check screenshot Commented Aug 20, 2019 at 9:19
  • there is no need to run chmod command because my magento installed in xampp windows OS in local computer. I did not installed on server Commented Aug 20, 2019 at 9:21
  • This may be a issue because of .htaccess file. Please check if there is .htaccess file under pub/static or not.
    – temper
    Commented Aug 20, 2019 at 9:36
  • or try to rename .htaccess file from your magento rot directory then check if it works.
    – temper
    Commented Aug 20, 2019 at 9:37

1 Answer 1

2
\vendor\magento\framework\View\Element\Template\File\Validator.php

Around line 133 find function isPathInDirectories

add

$realPath = str_replace('\\', '/', $realPath); // extra code added

like

protected function isPathInDirectories($path, $directories)
    {
        if (!is_array($directories)) {
            $directories = (array)$directories;
        }
        $realPath = $this->fileDriver->getRealPath($path);
        $realPath = str_replace('\\', '/', $realPath); // extra code added
        foreach ($directories as $directory) {
            if (0 === strpos($realPath, $directory)) {
                return true;
            }
        }
        return false;
    }
2
  • Awesome bro,it works fine,appreciated Commented Aug 20, 2019 at 9:31
  • @NirajPatel Thanks brother Commented Aug 20, 2019 at 9:36

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.