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 can AEM add hostnames?

Avatar

Avatar
Springboard
Level 3
jkpanera
Level 3

Likes

18 likes

Total Posts

107 posts

Correct Reply

2 solutions
Top badges earned
Springboard
Establish
Validate 10
Validate 1
Ignite 5
View profile

Avatar
Springboard
Level 3
jkpanera
Level 3

Likes

18 likes

Total Posts

107 posts

Correct Reply

2 solutions
Top badges earned
Springboard
Establish
Validate 10
Validate 1
Ignite 5
View profile
jkpanera
Level 3

06-05-2019

Hi guys,

We are seeing an issue in our production environment where links are being incorrectly substituted. Our author (and our code) only select resources from the JCR to build links. AFAIK, the links should be relative but we are actually seeing host names in the links.

For instance, if an author selects the resource /content/domain_com/en-us/locator, we expect to see the HTML:

  <a class="block-level list-item-link" href="https://forums.adobe.com/content/domain_com/en-us/locator.html" title="Locations" target="_self">Locations</a>

And in most environments, we do see that, but intermittently, we see this:

  <a class="block-level list-item-link" href="https://test-host.domain.com:4503/content/domain_com/en-us/locator.html" title="Locations" target="_self">Locations</a>

Ironically, we only see that in production.

We do have some sling redirects set up, but I'm not sure if they are the cause. My understanding is that they will only change relative paths-not add on a hostname.

The relevant sling redirect could be this:

/etc/map/http/test-host.domain.com.4503/content/panerabread_com/en-us.json

  {

"jcr:primaryType": "sling:Mapping",

"jcr:mixinTypes": [

"cq:ReplicationStatus"

],

"jcr:createdBy": "admin",

"jcr:created": "Fri May 18 2018 15:29:02 GMT-0500",

"sling:match": "en-us",

"sling:internalRedirect": [

"/content/domain_com/en-us",

"/content/domain_com/en-us/content"

]

}

But I'm not really sure.

FYI, we are running 6.3 SP1.

Any help would be appreciated.

Thanks much!

Replies

Avatar

Avatar
Coach
Employee
jbrar
Employee

Likes

389 likes

Total Posts

869 posts

Correct Reply

283 solutions
Top badges earned
Coach
Establish
Give Back 50
Give Back 5
Give Back 3
View profile

Avatar
Coach
Employee
jbrar
Employee

Likes

389 likes

Total Posts

869 posts

Correct Reply

283 solutions
Top badges earned
Coach
Establish
Give Back 50
Give Back 5
Give Back 3
View profile
jbrar
Employee

06-05-2019

Setup a DEBUG level logger on "org.apache.sling.resourceresolver" and compare it with a working instance.

Avatar

Avatar
Springboard
Level 3
jkpanera
Level 3

Likes

18 likes

Total Posts

107 posts

Correct Reply

2 solutions
Top badges earned
Springboard
Establish
Validate 10
Validate 1
Ignite 5
View profile

Avatar
Springboard
Level 3
jkpanera
Level 3

Likes

18 likes

Total Posts

107 posts

Correct Reply

2 solutions
Top badges earned
Springboard
Establish
Validate 10
Validate 1
Ignite 5
View profile
jkpanera
Level 3

06-05-2019

Thanks for your prompt reply JaideepBrar​. I'll try to get the logging added in production.  In the meantime, I poked around a bit and found this:

http://<publishhost>:4503/system/console/jcrresolver

There are five sections:

Configuration, Configuration Test, Resolver Map Entries, and Mapping Map Entries.

Resolver Map Entries look reasonable for the most part. They are things like:

Pattern:

https/test-host.domain.com.4503/content/domain_com/en-us

Replacement:

/content/domain_com/en-us

Redirect:

Internal

Fine. No problem. Then I look farther down at Mapping Map Entries. And I see:

Pattern:

^/content/panerabread_com/en-us/content

Replacement:

http://test-host.domain.com:4503/content/domain_com/en-us

http://another-test-host.domain.com:4503/content/domain_com/en-us

....

http://another-test-host.domain.com:4503/content/domain_com/en-us

Redirect:

external: 302

I can send a screenshot of the actual jcrresolver console, but I can't post it on the open web.

Here's the thing. We don't want any external redirects. We create all of our sling redirects as above (using sling:internalRedirect). Apparently it does both? Not sure how we can create a redirect that doesn't create a mapping both directions.

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

06-05-2019

Have you checked the mapping entry specification ?

Apache Sling :: Mappings for Resource Resolution

follow the example given in the above link and make appropriate entry

Avatar

Avatar
Springboard
Level 3
jkpanera
Level 3

Likes

18 likes

Total Posts

107 posts

Correct Reply

2 solutions
Top badges earned
Springboard
Establish
Validate 10
Validate 1
Ignite 5
View profile

Avatar
Springboard
Level 3
jkpanera
Level 3

Likes

18 likes

Total Posts

107 posts

Correct Reply

2 solutions
Top badges earned
Springboard
Establish
Validate 10
Validate 1
Ignite 5
View profile
jkpanera
Level 3

07-05-2019

Hi Hermant, we looked through that. We were able to disable many of the external redirects by changing them to be regexps, but we are still fiddling with it. Is there a way to turn off external redirects entirely?

Using the same mechanism for both direct and reverse mappings without an explicit switch is a thoroughly brain damaged design.

Avatar

Avatar
Boost 250
MVP
Gaurav-Behl
MVP

Likes

250 likes

Total Posts

1,147 posts

Correct Reply

283 solutions
Top badges earned
Boost 250
Establish
Give back 300
Give Back 50
Give Back 5
View profile

Avatar
Boost 250
MVP
Gaurav-Behl
MVP

Likes

250 likes

Total Posts

1,147 posts

Correct Reply

283 solutions
Top badges earned
Boost 250
Establish
Give back 300
Give Back 50
Give Back 5
View profile
Gaurav-Behl
MVP

07-05-2019

If the same content tree is mapped to multiple domains via sling mappings as in your case, it could very well lead to the issue as you have identified in resolver.

For turning off external redirects, you need to fix your sling mappings to remove "sling:redirect" properties appropriately per use case. 

Avatar

Avatar
Springboard
Level 3
jkpanera
Level 3

Likes

18 likes

Total Posts

107 posts

Correct Reply

2 solutions
Top badges earned
Springboard
Establish
Validate 10
Validate 1
Ignite 5
View profile

Avatar
Springboard
Level 3
jkpanera
Level 3

Likes

18 likes

Total Posts

107 posts

Correct Reply

2 solutions
Top badges earned
Springboard
Establish
Validate 10
Validate 1
Ignite 5
View profile
jkpanera
Level 3

08-05-2019

So after discussing with my team, we do actually need reverse mappings BUT we don't want external redirects. I.e. we only ever want absolute URLs used if the links in the content tree are absolute URLs. If there are relative URLs in the content, we wanted them to be relative (but mapped on a path basis).

But every example that I have seen has absolute URLs in the replacement column. Probably because there's always a host in the /etc/map tree. I.e. it's always something like /etc/map/http/hostname. Is there a way to create a mapping that isn't host specific?

Is there a way to do this?

Avatar

Avatar
Boost 250
MVP
Gaurav-Behl
MVP

Likes

250 likes

Total Posts

1,147 posts

Correct Reply

283 solutions
Top badges earned
Boost 250
Establish
Give back 300
Give Back 50
Give Back 5
View profile

Avatar
Boost 250
MVP
Gaurav-Behl
MVP

Likes

250 likes

Total Posts

1,147 posts

Correct Reply

283 solutions
Top badges earned
Boost 250
Establish
Give back 300
Give Back 50
Give Back 5
View profile
Gaurav-Behl
MVP

08-05-2019

Yes, you can create mappings that aren't host specific. A solution would be to use Sling Resource Resolver Factory - URL Mappings in /system/console/configMgr only for inbound urls but not for outbound urls

Do you share the root path with multiple domains that controlled via sling mappings? If yes, then you may modify your relative urls to keep the root rather than real-relative urls - that would prevent the domain-substitution to happen on publish servers.

You may share a sample sling:mapping rule structure if none of the above mentioned works out.

Avatar

Avatar
Springboard
Level 3
jkpanera
Level 3

Likes

18 likes

Total Posts

107 posts

Correct Reply

2 solutions
Top badges earned
Springboard
Establish
Validate 10
Validate 1
Ignite 5
View profile

Avatar
Springboard
Level 3
jkpanera
Level 3

Likes

18 likes

Total Posts

107 posts

Correct Reply

2 solutions
Top badges earned
Springboard
Establish
Validate 10
Validate 1
Ignite 5
View profile
jkpanera
Level 3

08-05-2019

gauravb10066713​ maybe you could give me an example of how I can do this?

I need to map /content/domain_com/en-us to /en-us. So for example, http://domain.com/en-us should be redirected to directed to the resource /content/domain_com/en-us BUT all links that are to /content/domain_com/en-us should be generated as /en-us regardless of the hostname in the request.

How can I do that?

Avatar

Avatar
Boost 250
MVP
Gaurav-Behl
MVP

Likes

250 likes

Total Posts

1,147 posts

Correct Reply

283 solutions
Top badges earned
Boost 250
Establish
Give back 300
Give Back 50
Give Back 5
View profile

Avatar
Boost 250
MVP
Gaurav-Behl
MVP

Likes

250 likes

Total Posts

1,147 posts

Correct Reply

283 solutions
Top badges earned
Boost 250
Establish
Give back 300
Give Back 50
Give Back 5
View profile
Gaurav-Behl
MVP

09-05-2019

As mentioned above in the second solution, use '/domain_com/en-us/...' as the relative url in your jsp/htl script rather than '/en_us/...', that should fix your issue.