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

Can you redirect to a .PDF?

  • May 6, 2016
  • 6 replies
  • 3460 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

leeaslingAccepted solution
New Participant
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.

New Participant
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. ???

New Participant
May 9, 2016

Im in CQ5

New Participant
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.

edubey
New Participant
May 7, 2016

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

It should work

smacdonald2008
New Participant
May 6, 2016

What version of AEM are you using?