Multilang 404 for IIS with AEM and Dispatcher

asked 2021-11-15T22:08:05.55+00:00
Bartosz Wesołowski 1 Reputation point

Hello,

I have an IIS set up wid Adobe Dispatcher for Adobe AEM project. In my setup IIS is a server in front of AEM server backend.

IIS is responsible for rewriting requests and passing them through Dispatcher module to the backend server. The dispatcher module is responsible for filtering requests and caching response html files. Filter module returns 404 status code if request is not allowed (filters out unwanted requests so the can not hit the backend server)

I would like to implement custom 404 pages, with the following requirements for my site www.mysite.com:

  1. When the url is www.mysite.com/en/not-existing I would like to serve custom en 404 page served from my backend server
  2. When the url is www.mysite.com/de/not-existing I would like to serve custom de 404 page served from my backend server
  3. When the url is www.mysite.com/not-existing I would like to serve default 404 which is the same as in the first scenario
  4. When Adobe Dispatcher filter does not accept given request it returns 404 status code and in this scenario I would also like to return defult 404 page

With Apache I could use ErrorDocument directive with RewriteCond to use proper 404 for given url. Is it possible to implement my requirements with OOTB IIS features ?

Internet Information Services
No comments
{count} votes

2 answers

Sort by: Most helpful
  1. answered 2021-11-16T03:06:36.593+00:00
    Bruce Zhang-MSFT 3,656 Reputation points

    Hi @Bartosz Wesołowski ,

    IIS has a module called Erro Pages can custom error page. You can add status code which you want to custom error page. You can also replace the error page while IIS has provided error page for specific status code.
    149586-1.jpg

    If you follow the path of IIS error page C:\inetpub\custerr, you will find many folder named different languages. So IIS has already defined different error pages in different languages for you in advance.
    149622-2.jpg
    149529-3.jpg

    So the easiest way is that you can directly replace the error pages in these folders. As long as it is a 404 error, IIS will respond to a customized page. IIS will determine which language the error page should be responded to based on the requesting client.

    You can also define the default error page.
    149588-4.jpg
    You can choose the path of the default page and the way to execute the path: file, error page URL and redirection.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,
    Bruce Zhang

    No comments

  2. answered 2021-11-16T13:54:26.61+00:00
    Bartosz Wesołowski 1 Reputation point

    Hi @Bruce Zhang-MSFT

    Thanks for your reply.

    Unfortunately in my case this does not solve the issue. As far as I understand this is uses static files saved on IIS level. In my project those 404 needs to be served from the AEM backend server as well (it is a CMS system) so I would like to have a configuration where if a request failed with 404 I issue a request to backend server to get custom 404 for given language (so CMS authors can change the 404 page and it will be available on the site without any IIS changes).
    Is that possible ?

    For now I pass the 404 response from the AEM as is and calculates the correct page content there but this has some issues (for example with the Dispatcher filtering) and I would like to move this logic to IIS (as it's done with Apache in most cases).

    And additionally - how IIS determines which language to use when the feature you described is used?

    Best regards,
    Bartek