Felix Meschberger wrote:
Hi Scott,

Scott Taylor schrieb:
I've just started playing around with Sling, and I would like to try to
move one of my web applications over to Sling. The application is just a
set of HTML pages, but it uses URLs without extensions. So instead of
urls like http://www.mydomain.com/mynode.html I would like to use
http://www.mydomain.com/mynode/ to return an HTML page. I tried creating
a GET.esp script, and while that caused an html page to be return when
no extension was present, it also affected the other extensions as well
(eg. .json). Basically I would like Sling to treat urls without
extensions as having an .html extension (but without using a redirect).
Is that possible? I believe I saw some discussion about this in the
email archives, but I'm not sure what the outcome was.

Any help greatly appreciated,
/Scott

With the recent extensions of the ResourceResolver it is now possible to
internally handle any request without an extensions as if it would have
an .html extension by defining an entry below /etc/map such as:

/etc/map/http/no_extension: {
    "jcr:primaryType": "sling:Mapping"
    "sling:internalRedirect": "http://$1:$2$3.html";,
    "sling:match": "([^/]+)\\.(\\d+)(/(.*/)?[^/^.]+)/?$",
}

using curl, the following command line should do the trick:

  $ curl -u admin:admin -Fjcr:primaryType=sling:Mapping \
         -F"sling:match=([^/]+)\\.(\\d+)(/(.*/)?[^/^.]+)/?$" \
         -F"sling:internalRedirect=http://\$1:\$2\$3.html"; \
         http://localhost:8888/etc/map/http/no_extension

For this to work, you need the current trunk of the jcr/resource module
installed.

Hope this helps.

Regards
Felix
Unfortunately I didn't get it to work after building from the current trunk, but I found I was able to basically get the desired result by creating a node called index under the node "mynode". The url http://www.mydomain.com/mynode would return a html page based on the properties in the index node. I may revisit this later as I think the solution you mentioned might be cleaner for my purposes, but the index solution is good enough for now. Thanks for the help!

/Scott

Reply via email to