Expand my Community achievements bar.

SOLVED

AEM Url shortening functionality

Avatar

Level 4

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
1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

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

View solution in original post

5 Replies

Avatar

Level 3

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/-/

Avatar

Level 4

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.

Avatar

Correct answer by
Employee Advisor

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

Avatar

Level 4

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$:/

Avatar

Employee Advisor

According to the documentation "/content/site:/" should be the right rules.