I have folder with images in root directory and I need deny to access that images from URL.
I have .htaccess
in this folder
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http(s?)://(www.)?localhost.*$ [NC]
RewriteRule .(gif|jpg|jpeg|png)$ - [F]
This works perfect and if try to access image via URL, it shows error
Forbidden
You don’t have permission to access ..
But I want instead, redirect to my custom error page (which is /error
controller in my case).
What is correct .htaccess
syntax for this?
2
Answers
specify
after line
RewriteEngine on
so it will be like this :
It should be something like this:
Have a look at this link http://www.javascriptkit.com/howto/htaccess2.shtml
I’m not sure that it would work with a route, maybe you have to specify a document.
I’d try it though.