After spending a few days (or weeks!) looking for information related to hiding parts of URLs with Apache Web Server and Adobe Experience Manger, I believe I may have pulled it all together. This is my attempt at explaining how it works.
Out of the box, everything works due to the full path being used from the browser -> web server -> cache and if a page is updated the Flushing agent is able to invalidate the proper page due to the path being the same in AEM as in the cache.
Now, since I am a developer and I have access to create my own resource mapping, I am going to add a configuration and point a shortened URL to my landing page.
Sling:internalRedirect string /content/geometrixx/$1
Sling:match string site.com/en(.*)$
I save it, replicate it to publish and try it out. Click, http://site.com/en.html, sweet it works. Wow that was easy, looks good, all done! Wait a minute, when I update the page it doesn’t seem to show up properly to the user, what is going on?
Let’s take a look.
Ok, so my Browser -> Web Server -> Cache is all looking for site.com/en.html, and the mapping in AEM points it to /content/geometrixx/en.html, so it works from that end, but my Flushing agent is invalidating /content/geometrixx/en.html in the cache, which never exists! The cache is putting my page at /en.html! Well that works the first time, but if I need to update the page I will need to clear the cache every time and my Flushing Agent will be doing nothing for me.
Well scratch that, let me try to do this on the web server. I think I remember something about RewriteRule…
RewriteRule ^/$ /content/geometrixx/en.html [PT]
Ok, now when something comes in, it goes to my landing page and in the correct cache folder.
Nice! This works, the cache looks good and the Flushing agent can invalidate the page! So I click on another link on the page and then the whole path pops up again! I guess this is good enough, who really looks at the URL once they are in the site anyways. Said no customer ever….
Well, let’s try putting them together!
This works on the initial call and all following calls to en.html, but why? Here is the breakdown.
First, you will notice the RewriteRule is slightly different.
RewriteRule ^/content/geometrixx/ ^/$1 [PT]
This lets site.com/en.html through with no changes because it does not match the filter and the mapping in AEM points it to /content/geometrixx/en.html. When the Flushing Agent fires off, it hits the filter in the web server and is written to /en.html, so it invalidates the proper page. So everything seems to work, the only issue is the caching does not reflect the folder structure in AEM. If cache structure is not a consideration for your project, then this solution could work.
You will notice we only took one page, en.html, into consideration, along with only the content folder. A final solution for all assets is more complex and I am working on a write up for it. Also, I am looking into only having setting on the web server so I can keep everything in one spot.