Expand my Community achievements bar.

SOLVED

Adding Canonical URL to PDFs

Avatar

Level 1

We are using AEMaaCS. We have an requirement to add canonical URL to PDFs. Please suggest me how to add it through dispatcher configuration. 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

you can write a rewrite rule matching you dam asset path. The rule will add a Link header to the response, with the value of the header being the canonical URL of the PDF.

Something like  

 Header set Link 'FILENAME; rel="canonical"'

 

View solution in original post

3 Replies

Avatar

Community Advisor

Hi @DivyaT 

You can try by adding the below snippet as part of the rewrite rules

In the dispatcher module you can use "/dispatcher/src/conf.d/rewrites/rewrite.rules" to add the changes

 

RewriteRule ([^/]+)\.pdf$ - [E=FILENAME:$1]

<FilesMatch "\.pdf$"> Header add Link '<http://www.example.com/download/%{FILENAME}e>; rel="canonical"'

</FilesMatch>

 

Also please refer this below link

https://www.danielmorell.com/guides/htaccess-seo/crawling-indexing/put-rel-canonical-on-non-html-res...

 

 

Hope this helps

 

 

Avatar

Correct answer by
Community Advisor

you can write a rewrite rule matching you dam asset path. The rule will add a Link header to the response, with the value of the header being the canonical URL of the PDF.

Something like  

 Header set Link 'FILENAME; rel="canonical"'

 

Avatar

Administrator

@DivyaT Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.



Kautuk Sahni