Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

How to implement pretty URLs in AEM? (URL parameters but without using ?parameter-here=xxx)

Avatar

Avatar
Validate 25
Level 4
jayv25585659
Level 4

Likes

46 likes

Total Posts

117 posts

Correct Reply

0 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Contributor 2
Ignite 5
View profile

Avatar
Validate 25
Level 4
jayv25585659
Level 4

Likes

46 likes

Total Posts

117 posts

Correct Reply

0 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Contributor 2
Ignite 5
View profile
jayv25585659
Level 4

17-04-2018

I want to create a URL like this.

www.myhost.com/my-page/john.smith

my-page is an AEM page while john.smith is a parameter to the page. It's really like

www.myhost.com/my-page?name=john.smith

but the first URL that looks nicer. Is this something AEM can do (like config changes) or perhaps this is an Apache rewrite rules? Perhaps combination of both?

Sample please?

Thanks!

Replies

Avatar

Avatar
Validate 1
Level 10
edubey
Level 10

Likes

273 likes

Total Posts

1,502 posts

Correct Reply

392 solutions
Top badges earned
Validate 1
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Validate 1
Level 10
edubey
Level 10

Likes

273 likes

Total Posts

1,502 posts

Correct Reply

392 solutions
Top badges earned
Validate 1
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile
edubey
Level 10

17-04-2018

Your first URL goes towards selector implementation in AEM,


Look at the complete guide here https://helpx.adobe.com/experience-manager/6-2/managing/using/seo-and-url-management.html

Avatar

Avatar
Validate 25
Level 4
jayv25585659
Level 4

Likes

46 likes

Total Posts

117 posts

Correct Reply

0 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Contributor 2
Ignite 5
View profile

Avatar
Validate 25
Level 4
jayv25585659
Level 4

Likes

46 likes

Total Posts

117 posts

Correct Reply

0 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Contributor 2
Ignite 5
View profile
jayv25585659
Level 4

17-04-2018

thanks! I searched but your link didn't come up.

Avatar

Avatar
Validate 1
Level 7
Hemant_arora
Level 7

Likes

92 likes

Total Posts

290 posts

Correct Reply

54 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 1
Give Back 50
View profile

Avatar
Validate 1
Level 7
Hemant_arora
Level 7

Likes

92 likes

Total Posts

290 posts

Correct Reply

54 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 1
Give Back 50
View profile
Hemant_arora
Level 7

17-04-2018

You can add a sling mapping for making your pages load with URL 1

You can perform a regular expression matching which matches all url with extension .smith and redirect internally in AEM to /content/my-page/john

Refer to https://sling.apache.org/documentation/the-sling-engine/mappings-for-resource-resolution.html#mappin...

Avatar

Avatar
Validate 25
Level 4
jayv25585659
Level 4

Likes

46 likes

Total Posts

117 posts

Correct Reply

0 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Contributor 2
Ignite 5
View profile

Avatar
Validate 25
Level 4
jayv25585659
Level 4

Likes

46 likes

Total Posts

117 posts

Correct Reply

0 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Contributor 2
Ignite 5
View profile
jayv25585659
Level 4

23-04-2018

with URL mappings, can this be tested locally (dev laptop that's running an author instance of AEM. no publisher. no dispatcher)? I'm only asking since the URL you linked mentioned dispatcher and Apache rewrite rules.

Thanks

Avatar

Avatar
Validate 1
Level 7
Hemant_arora
Level 7

Likes

92 likes

Total Posts

290 posts

Correct Reply

54 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 1
Give Back 50
View profile

Avatar
Validate 1
Level 7
Hemant_arora
Level 7

Likes

92 likes

Total Posts

290 posts

Correct Reply

54 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 1
Give Back 50
View profile
Hemant_arora
Level 7

23-04-2018

Yes it can be tested locally. no publish no dispatcher required

Avatar

Avatar
Validate 10
Level 3
anjali_biddanda
Level 3

Likes

17 likes

Total Posts

69 posts

Correct Reply

6 solutions
Top badges earned
Validate 10
Validate 1
Give Back 5
Give Back 3
Give Back
View profile

Avatar
Validate 10
Level 3
anjali_biddanda
Level 3

Likes

17 likes

Total Posts

69 posts

Correct Reply

6 solutions
Top badges earned
Validate 10
Validate 1
Give Back 5
Give Back 3
Give Back
View profile
anjali_biddanda
Level 3

06-05-2018

You'll need to use a sling servlet with a selector. Your selectors will be firstname, lastname. Your sling servlet annotation will look like this:
@SlingServlet(resourceTypes = "myBrand/components/pages/myPeoplePageType", selectors =

{firstname, lastname}

, extensions = "html”, methods=”GET”)

Your URL below:
http://www.myhost.com/people.firstname.lastname
will invoke your servlet and pass current page path along with other parameters. Servlet would be resolved through selectors & resource type.

Then you will need a dispatcher rewrite rule that will take /my-page/john.smith and transform it into /my-page.john.smith. You can test your /my-page.john.smith on your author instance. But for the pretty URL, you'll need your dispatcher set up. Or you might be able to do this URL mapping (under /etc/maps) as a regexmap (https://sling.apache.org/documentation/the-sling-engine/mappings-for-resource-resolution.html#mappin...), in which case, you can test it in your author.

https://forums.adobe.com/thread/2325530
http://www.aemcq5tutorials.com/tutorials/sling-servlet-in-aem/
https://helpx.adobe.com/experience-manager/6-2/managing/using/seo-and-url-management.html (Look at sections - "Using Sling Selectors" and "Sling servlets (one level down)")