Cloud 5 - Fix Your… Rewrites

Part two of the series, we explore some things that you can look at that will speed up your rewrite development and optimization on AEM as a Cloud Service.

Transcript
So, James, welcome back to the part two of the Fix Your… series in this case, - we’re going to fix your rewrite. So let me jump right into it. What is the most common rewrite that AEM developers use. Hey, Darin - it’s - great to see you as always. And, you know, without a doubt, - the removal of the slash content slash site name from the requested - URL is the most common one that we see. In fact, it’s so common, it’s - now in the default AEM archetype. A close second is using rewrites - for vanity URLs and redirects for pages that have been bookmarked - and now are moved to a new location. As you can see below, it should be noted that Mod Rewrite is not an Adobe product, but is probably the most used - module used by the Apache Web server. This means that there’s lots of content on the web for finding documentation - and tools for doing that development.
I know that mod rewrite is a very powerful tool, - which means there are probably some things that can cause some issues in your AEM - deployments. What are some of the common gotchas? Oh, yeah, that’s - that’s a really good point, Darin. And the number one issue that we see is - when the rewrite rules you create change, the cached invalidation - requests, the default invalidation passed our dispatcher invalidate dot cache - and should remain untouched if you want publish activations - to invalidate those dispatcher paths. Now, number two apply - specific to cloud service deployment when your rewrite changes - some of the default URLs that cloud manager uses to validate - the health of your environment, you can use some of the online - htaccess tools to debug and validate - these things before going to production.
Well, you mentioned before that many people use rewrites - to handle vanity and redirects. What are some of the tips you can provide - to provide that capability? Yeah, no. Great question, Darin. By example, let’s say - you have a landing page that’s buried somewhere in that site hierarchy - and marketing wants to provide access to that page on some marketing materials, - and you don’t want to have people hand enter a long URL that might be prone - to typos or fat fingering. There really a couple of options. You can use the vanity URL feature - that AEM provides. It’s easy to use by marketers and - can be implemented really, really quickly. It does however, have some downsides. Depending on the URL you come up with, - it might not be catchable, adding an unnecessary load. Plus, if you use these extensively - things can quickly become unmanageable - in addition to performance problems. Honestly, my favorite option - is just to use mod rewrite to handle things like this. This rewrite rule that you see here. And again, in this case, - we’re using the contact us, but it basically takes a path - like Contact US that you see here - and redirects to the HTML page. And let’s look carefully. You could see some of the flags - that are in use here. NC means that it’s case insensitive - and the R is the type of redirect - you want to be set. Another common example is mapping - the favicon to another location So here’s a rewrite rule - that does exactly that. And this rule matches - the entire requested UI from the carrot to the dollar sign - The flags used here are the same, except for the PT flag, - which designates this as a pass through rule which preserves - the original requested URL.
Well, cool. Are there any tools that can help - test out these rewrites before deploying? Oh yeah. There are a lot of different tools - that are available online for testing out rewrites - and regular expressions. I don’t really want to recommend - any one over the other, but most are really good at finding - obvious errors we’ll post some tools below - that you can use to test your rules out. Once you have the rules sorted out, - you can use the AEM SDK supplied dispatcher tools - to try them out with a live system. Now, we’ve covered these tools - in past episodes that you can reference to get you started. Yeah, great questions, Darin - - and thank you. Thank you, James.

Content covered in this video

recommendation-more-help
4859a77c-7971-4ac9-8f5c-4260823c6f69