Hi @tb3dock!
In general, filters do apply to all requests so the answer to your question if filters can be included into request processing for pages is: yes. Please refer to the example filter implementation of the AEM Maven Archetype for an example [1].
That being said, I strongly discourage to build a custom rewriting or ruling mechanism into AEM. This will probably interfere with various AEM and Sling features and mechanisms and potentially break things. You really don't want to go down that rabbit whole.
There are two alternative approaches here:
- Use the according Apache httpd and dispatcher features
It's totally possible to test this on a local environment and the AEM Cloud SDK even includes a Dispatcher. I recommend to have at least one (local or server) dev environment in every project that includes a full setup with author and publish instances plus dispatcher for this kind of development.
Handling rewriting and redirects on the dispatcher level comes with performance advantages and reduces load to the AEM instances. Shying away from this approach because you just don't want to setup a local dispatcher is IMHO not a very resilient argument against it. You will have a dispatcher in production and you really should have a proper setup to develop and test your configurations on the lower/lowest stages as well. - Use the existing AEM features for Resource Mapping [3] such as
- JCR Resource Resolver and/or
- AEM Mapping Definitions (/etc/map)
Personally, I prefer a combination of rewrite rules on the dispatcher level and link rewriting on the AEM side as outlined in this article [4] .
Please note that this always has two components:
- Routing incoming requests to the correct path/resource (e. g. mysite.com/home.html to /content/mysite/de/de/home) and
- Rewriting links inside the page/components (e. g. shortening /content/mysite/de/de/home.html to /home.html in href attributes)
Hope that helps!
[1] https://github.com/adobe/aem-project-archetype/blob/develop/src/main/archetype/core/src/main/java/core/filters/LoggingFilter.java
[2] https://experienceleague.adobe.com/docs/experience-manager-cloud-service/implementing/developing/aem-as-a-cloud-service-sdk.html?lang=en
[3] https://experienceleague.adobe.com/docs/experience-manager-65/deploying/configuring/resource-mapping.html?lang=en
[4] https://helpx.adobe.com/in/experience-manager/kb/multi-domain-management-aem-mappings-for-url-shortening---aem-6-.html