After upgrading Magento to 2.3, My website's frontend is working fine with complete CSS. however, I am unable to open admin-backend when I hit the admin URL. it is only loading but the admin-login page is not opening in the End 500 error is displaying on the browser. do anyone know why it is occurring.
2 Answers
Overide the code in,
vendor/magento/framework/View/Element/Template/File/Validator.php
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;
}
You can override vendor\magento\framework\View\Element\Template\File\Validator.php Using preference
Just Create a custom module and add below code to your di.xml file
now create the class [VENDOR][EXTENSION]\View\Element\Template\File\Validator that extends Magento\Framework\View\Element\Template\File\Validator
Copy that code and replace the below function,
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;
}
-
This is bad practise, you should not be editing core code like this, especially code in the vendor directory!– eddhallCommented May 27, 2019 at 12:51
-
-
Did you overide the file or Replace that code directly in vendor file?– aravindCommented May 27, 2019 at 13:11
-
-
remove overide and add that code directly in vendor and check– aravindCommented May 27, 2019 at 13:35
I had the same problem and fixed it by the below solution. You may try it
-
-
Please try to run the below commands from the Magento root installation rm -rf var/di/* var/generation/* var/cache/* var/log/* var/page_cache/* var/session/* var/view_preprocessed/* pub/static/* php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento setup:static-content:deploy -f php bin/magento indexer:reindex php bin/magento cache:flush– SivaCommented May 27, 2019 at 13:14
-
rm -rf generated/ var/view_preprocessed var/page_cache , php bin/magento setup:upgrade , condtent deplot and last permission 777 command all the command run but result is same Commented May 27, 2019 at 13:29