Can you redirect to a .PDF? | Community
Skip to main content
Level 2
May 6, 2016
Solved

Can you redirect to a .PDF?

  • May 6, 2016
  • 6 replies
  • 3477 views

I know how to redirect to a page...but do not know how to redirect to a .PDF. For example I want the title in the MegaMenu but simply redirect to the PDF, not to a page. Is this possible?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by leeasling

That's because OOTB the redirect functionality checks to see if the location is internal or external (see /libs/foundation/components/page/page.jsp).  If it determines it's internal (i.e. doesn't contain :/) then it appends .html

You could overlay the page.jsp in your page component and check to see if ".pdf" exists, and if it does, don't append .html and if it does, just perform the redirect.

6 replies

smacdonald2008
Level 10
May 6, 2016

What version of AEM are you using?

edubey
Level 10
May 7, 2016

Instead of providing link to a page, provide the path to .pdf file

It should work

Level 8
May 8, 2016

You can absolutely do that by either pointing to the asset in the DAM, or by specifying an absolute URL.  The trick from an SEO perspective is that you'll want to open it in a new window so you keep people on your site.  We typically use a link helper class where the link path/url is passed into a sightly class and the logic determines whether it's an internal page and needs to be appended with .html, or whether it's external/an asset, and will set the _blank attribute on the anchor.

Level 2
May 9, 2016

Im in CQ5

Level 2
May 9, 2016

When I go the advanced tab under properties, and use the redirect, I see the file as a .pdf. However, when I go to the live version it wants to take me to a.html. ???

leeaslingAccepted solution
Level 8
May 9, 2016

That's because OOTB the redirect functionality checks to see if the location is internal or external (see /libs/foundation/components/page/page.jsp).  If it determines it's internal (i.e. doesn't contain :/) then it appends .html

You could overlay the page.jsp in your page component and check to see if ".pdf" exists, and if it does, don't append .html and if it does, just perform the redirect.