I am trying to redirect external links to pdf files to the html page were the pdf is hosted.
I have updated /etc/apache2/conf.d/includes/pre_main_global.conf, which is an include file for httpd.conf with:
#rewriteMap to stop hotlinking
RewriteMap pdf-mapping txt:/home/stakehol/public_html/pdf-mapping.txt
pdf-mapping.txt contains:
/stakeholder-register.pdf /stakeholder-register.html
/project-templates/lessons-learned-template.pdf /project-templates/lessons-learned-template.html
/project-templates/Exception%20Report.pdf /project-templates/prince-2-exception-report.html
It will have hundreds of urls, but these three are just for testing.
In .htaccess I have added:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www.)?stakeholdermap.com [NC]
RewriteCond ${pdf-mapping:$1} !^$
RewriteRule ^(.*.pdf)$ https://www.stakeholdermap.com/${pdf-mapping:$1} [R=302,L]
I have restarted apache and the pdf files aren’t redirecting. Ready to give up and just add links in the pdfs back to the page, but I want to charge for the pdfs at some point so…