I'm having a problem since I'm new to Magento.
how can I create a custom error pages in my Magento 2 site?
For example these pages: 500, 401, 403, and 404. I hope someone can help me.
Thanks
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityyou can customize (404) page from admin
Content->Pages->404 Not Found->Edit->content
here you can change whatever content you need.
If you look programmatically solution, add the below content in your <root-magent>/app/code/Vendor/Module/etc/di.xml
<type name="Magento\Framework\App\Router\NoRouteHandlerList">
<arguments>
<argument name="handlerClassesList" xsi:type="array">
<item name="default" xsi:type="array">
<item name="class"
xsi:type="string">Vendor\Module\Controller\NoRouteHandler</ite
m>
<item name="sortOrder" xsi:type="string">200</item>
</item>
</argument>
</arguments>
</type>
add this content in above mentioned controller
<?php
namespace Vendor\Module\Controller;
class NoRouteHandler implements \Magento\Framework\App\Router\NoRouteHandlerInterface {
public function process(\Magento\Framework\App\RequestInterface $request) {
$moduleName= 'cms';
$controllerName = 'index';
$actionName= 'index';
$request
->setModuleName($moduleName)
->setControllerName($controllerName)
->setActionName($actionName);
return true;
}
}
In this controller you can set whatever module/controller/actionname for 404 page.
follow this link to set 401,403,500 page