title: Laravel guest middleware
body: <p>I have a page in my web app that should be blocked from logged in users. Similar to how a login or register page should not be accessible to already logged in users. I accomplished this by using guest middleware in controller constructor.</p>
  
  <pre><code>$this-&gt;middleware("guest")-&gt;only("page_action"); // like this
  </code></pre>
  
  <p>In this setup, if logged in user tries to visit that page they get redirected to home page. But I need to show a 404 not found page instead of redirecting. How can I do that?</p>
  
  <p>In short, how can I make a page accessible to guest only and make it look like it does not exist to logged in users?</p>