Expand my Community achievements bar.

Applications for the 2024-2025 Adobe Experience Manager Champion Program are open!
SOLVED

Vanity URLs with extension problem

Avatar

Level 2

 Hi, all.

For the requirement I am currently working on we do need to have vanity URLs that include extensions, so we can maintain the same address from the current site when migration to AEM is complete (ex.: the vanity URL should be /foo/bar/foobar.aspx). But we could verify while testing that vanity URLs with extensions are not handled the way we expected, as the extension is meaningful to AEM to resolve how to render a given content.

Do you have any recommendations to this case? I'd like not to use a solution on the Apache leve (eg.: use mod-rewrite for removing the extension from the URL)? 

The exception I get when I set the vanity URL "foo/bar/foobar.aspx" to a page is displayed below:

Cannot serve request to /foo/bar/foobar.aspx in org.apache.sling.servlets.get.DefaultGetServlet
Request Progress:
      0 (2014-01-14 13:48:43) TIMER_START{Request Processing}
      0 (2014-01-14 13:48:43) COMMENT timer_end format is {<elapsed msec>,<timer name>} <optional message>
      0 (2014-01-14 13:48:43) LOG Method=GET, PathInfo=/foo/bar/foobar.aspx
      0 (2014-01-14 13:48:43) TIMER_START{ResourceResolution}
      0 (2014-01-14 13:48:43) TIMER_END{0,ResourceResolution} URI=/foo/bar/foobar.aspx resolves to Resource=JcrNodeResource, type=cq:Page, superType=null, path=/content/geometrixx-media/en
      0 (2014-01-14 13:48:43) LOG Resource Path Info: SlingRequestPathInfo: path='/content/geometrixx-media/en', selectorString='null', extension='aspx', suffix='null'
      0 (2014-01-14 13:48:43) TIMER_START{ServletResolution}

Regards,

Rafael

1 Accepted Solution

Avatar

Correct answer by
Level 8

One option would be to use /etc/map to do an internal Sling redirect from .aspx to .html, but I am not sure how that would play with the vanity URL. You'd have to test that out and see if you needed the vanity URL to be .aspx or .html after the internal redirect. Also to make sure that one wouldn't just override the other. 

If /etc/map doesn't work then you options I think are fairly limited. One of option I can think of that is sort of a hack but it would probably work:

  1. First you have set up a proxy for .aspx extension for the cq:Page node type - see http://helpx.adobe.com/experience-manager/kb/CQ53HowToAddACustomPageExtension.html for details. 
  2. Second you have to set up a JSP for aspx extensions at you base page. Exactly where this would go depends on how you implemented you pages, but as an example in geomettrix you would create /apps/foundation/components/page/page.aspx.jsp. This JSP would then do an include of the HTML version - <%@include file="/libs/foundation/components/page/page.jsp" %>.

I have never done that so I won't guarantee that you won't run into other problems but it will get your past your first problem. Unfortunately doing something at the Apache layer is probably your best solution to the problem. 

View solution in original post

3 Replies

Avatar

Correct answer by
Level 8

One option would be to use /etc/map to do an internal Sling redirect from .aspx to .html, but I am not sure how that would play with the vanity URL. You'd have to test that out and see if you needed the vanity URL to be .aspx or .html after the internal redirect. Also to make sure that one wouldn't just override the other. 

If /etc/map doesn't work then you options I think are fairly limited. One of option I can think of that is sort of a hack but it would probably work:

  1. First you have set up a proxy for .aspx extension for the cq:Page node type - see http://helpx.adobe.com/experience-manager/kb/CQ53HowToAddACustomPageExtension.html for details. 
  2. Second you have to set up a JSP for aspx extensions at you base page. Exactly where this would go depends on how you implemented you pages, but as an example in geomettrix you would create /apps/foundation/components/page/page.aspx.jsp. This JSP would then do an include of the HTML version - <%@include file="/libs/foundation/components/page/page.jsp" %>.

I have never done that so I won't guarantee that you won't run into other problems but it will get your past your first problem. Unfortunately doing something at the Apache layer is probably your best solution to the problem. 

Avatar

Employee Advisor

Hi,

this sounds a bit hard to do, because vanity URLs are suppossed to have no extension. The trick orotas proposed does work when you have a file and you just need to have a different extension, so when your old URL is "/content/foo.aspx" and the new one "/content/foo.html" (and even then I would do a permanent redirect, so the new URL is picked up).

You probably need to cut off the extension first and then handle the remaining part via the standard vanity URL mechanism. Sling mapping could to the cut off part, although I haven't tried this specific trick with it.

Jörg

Avatar

Level 2

Hi, Orotas and Jörg,

I've been playing with the /etc/map before, with no luck.

I'll try the hack proposed by Orotas, and report back in here if it works (or not) as soon as I finish it.

Regards.