Search code examples
apachemod-rewriteaem

Redirecting all 403 forbidden request to 404 page in aem


I am trying to redirect all forbidden request to 404 'not found' page. Url I am trying to access. http://localhost:4503/content/mysite/home.html (it is working fine). But when I try to access, http://localhost:4503/content/mysite (it is forbidden here). My site is developed in adobe experience manager and I don't see any config/setting related with redirecting. So, I have to do something on web server which is Apache here. And I am not pretty much familiar with Apache and creating rules in it. I would like to ask if there is anything that redirect any forbidden request to 404 not found page.


Solution

  • You can apply a simple rule in dispatcher using /filter section to specify the HTTP requests that Dispatcher accepts. All other requests are sent back to the web server with a 404 error code.

    In your case, it could be something like.

    /filter {
        /0001  { /glob "*" /type "deny" }
        /0002 { /type "allow" /method "POST" /url "/content/mysite/[.]*.html" }
    }
    

    This will first deny access to all files and then allow access to specific content, which *.html pages under /mysite in this case.