In Laravel how to redirect to 404 page on accessing post route

Author - Dalbir Kaur

In Laravel, when a user directly accesses a post route then an exception page is shown. How to show a 404 page instead?

To fix this issue :

Firstly, you need to create an error page in view folder of your project like 404.blade.php and put content in it (sample below):

Lastly, open your route file web.php and add following text to it:

In this, I have used get() to handle the request to post route. Now if anybody attempts to open this URL directly then automatically control transfers to the 404 page.


Webner Solutions is a Software Development company focused on developing Insurance Agency Management Systems, Learning Management Systems and Salesforce apps. Contact us at for your Insurance, eLearning and Salesforce applications.

Leave a Reply

Your email address will not be published.