In a website builded with Joomla!, I would redirect an external pdf request to a page where the pdf is embedded using iframe or object element.
I tried to do it via htaccess but it doesn't work. It seems that HTTP_REFERER doesn't work well. It seems that the request of embedded pdf is treated as an external request.
When I request mywebsite.com/pdf/filename.pdf, I get redirected to mywebsite.com/filename but also the embedded pdf itself is redirected to mywebsite.com/filename in a infinite loop!
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^mywebsite\.com [NC]
RewriteRule ^pdf/\filename\.pdf$ http://website.com/filename [R=300,L]
Here is the html code of the embedded pdf:
<object data="/pdf/filename.pdf" type="application/pdf">
<p>This browser does not support PDFs.</p>
</object>
Is there anybody who can help me to understand what's the catch?
How can I redirect an external request of pdf to a page where is the embedded pdf?
Thanks!