Blank Admin Page - Magento 2

Blank Admin Page - Magento 2


If you are using magento version 2.3.x or later then you may receive blank admin page after successful installation of magento 2.

You are receiving this error because real path is not correct to display admin page.

Locate the file validator.php in your magento root directory on path :

/vendor/magento/framework/View/Element/Template/File/Validator.php

In this file search below method code :


                                protected function isPathInDirectories($path, $directories)
                                {
                                    if (!is_array($directories))
                                    {
                                        $directories = (array)$directories;
                                    }
                                    foreach ($directories as $directory)
                                    {
                                        if (0 === strpos($this->fileDriver->getRealPath($path), $directory))
                                        {
                                            return true;
                                        }
                                    }
                                    return false;
                                }
                            

And replace the method code with :


                                protected function isPathInDirectories($path, $directories)
                                {
                                    $realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path));
                                    if (!is_array($directories))
                                    {
                                        $directories = (array)$directories;
                                    }
                                    foreach ($directories as $directory)
                                    {
                                        if (0 === strpos($realPath, $directory))
                                        {
                                            return true;
                                        }
                                    }
                                    return false;
                                }
                            

Run command php bin/magento cache:flush , clear cache of your browser and refresh page again.

You can see the login screen for admin will be displayed on admin page now.

For any suggestions, reviews or queries Contact Us