Skip to content

Instantly share code, notes, and snippets.

@masiorama
Created January 9, 2013 15:07
Show Gist options
  • Save masiorama/4493819 to your computer and use it in GitHub Desktop.
Save masiorama/4493819 to your computer and use it in GitHub Desktop.
Apache: set canonical urls for files insice .htaccess
#get all the pdfs and set a canonical url using the name of the file as pagename
RewriteRule ([^/]+)\.pdf$ - [E=FILENAME:$1]
<FilesMatch "\.pdf$">
Header add Link '<http://example.com/httest/%{FILENAME}e.html>; rel="canonical"'
</FilesMatch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment