AEM Url shortening functionality

karanmahi

21-06-2019

I need to implement url shortening functionality in two ways. First, I don’t want to show site structure (/content/site/en/..) in browser url. Secondly, <a href>  url on component should show only short url instead of complete page hierarchy (not starting with /content). I have seen multiple forums, but got confused between which one to use when? Can somebody please explain the use of these?

  1. Sling Mappings – under etc/map
  2. Apache Sling Resource Resolver Factory – I do see (Url Mapping and Mapping location properties there) - why are both configured?
  3. Apache 2 mod rewrite
  4. Virtual Host Re-direction

Accepted Solutions (1)

Accepted Solutions (1)

Jörg_Hoh

Employee

22-06-2019

Sling Mapping:

* works and you can implement even complex scenarios (e.g. different rules for different hostnames)

* is complicated to configure and design a ruleset

Sling Resource Resolver Factory

* can implement only simple cases (e.g. remove /content/mysite from all urls),

Apache mod_rewrite

* easy to use, good understanding and help available

* Only rewrites incoming requests, does not rewrite links inside HTML

Vhost redirect
* probably less features than mod_rewrite but with the same limitations

Answers (4)

Answers (4)

vijkumar

22-06-2019

Hi Karan,

Resource Resolver Factory is the solution for your case; just configure url mapping like [1] it will hide the configured content hierarchy in both the cases, url and anchor tags. Check the url mapping description in configuration for more details

[1] /content/site/en/-/

karanmahi

22-06-2019

thanks Joerg.

Does sling mapping and Sling Resource Resolver Factory both support url shortening both ways (inbound and outbound). I mean in the browser and in <a> tag?

What is the format to provide two-way mapping in Sling Resource Resolver Factory? I tried with colon ":", but it didn't work with /content/site/en/rps.html$:/

karanmahi

22-06-2019

Thanks, @vijkumar. I am more interested in knowing in which scenarios, I should use other options as mentioned in the original ticket. I mean what is the pros and cons of using each option.