We have the following website structure:
content
mysite
en
home
testlevel1page
testlevel2page
Now the requirement is to map:
- http://www.mysite.com/ --> /content/mysite/en/home.html
- http://www.mysite.com/testlevel1page/ --> /content/mysite/en/home/testlevel1page.html
- http://www.mysite.com/testlevel1page/testlevel2page/ --> /content/mysite/en/home/testlevel1page/testlevel2page.html
How can we achieve this through resource resolver?
Under the /etc/map/http
directory, add a node "www.mysite.com" and give this a sling:internalRedirect
property of /content/mysite/en/home
.
As per the Sling documentation, this will "prefix the URI paths of the requests sent to this domain with the string" — i.e. in this case, appending "/content/my/en/home" after the domain name for any incoming requests to "www.mysite.com".
Optionally, if you place this under /etc/map.publish/http
, this will only be applied to instances with a Sling run mode set to publish.
(As the rule is under a node called 'http', this won't be applied to secure requests. If you need to cater for 'https' too, you could copy the http node, or preferrably create a regex — this isn't as common a use case, but more info on the docs linked above.)
来源:https://stackoverflow.com/questions/21194654/url-mapping-based-on-resource-resolver-in-aem