Forum Moderators: phranque
With .htaccess in some subfolders, I'm finding the root .htaccess doesn't work in those folders.
For instance:
subfolder .htaccess
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^.*foo.*$
ReWriteRule .*\.(gif¦jpg)$ - [F]
Blocking gif and jpg from anything but referrer foo
That is all there is in that subfolder .htaccess
In the root .htaccess there is
RewriteCond %{HTTP_REFERER} ^.*\.badbot/$
RewriteCond %{HTTP_REFERER} !^http://websiteokay.*$
ReWriteRule ^ /folder/special\.html [L]
redirecting any referrer with badbot/ at the end if it is not
[websiteokay...]
Both root and subfolder .htaccess work fine.
referer badbot/ is redirected for all files in all folders
referrer [websiteokay...] is allowed
but these instructions are ignored in the subfolder with the .htaccess
referer badbot/ is getting through and not being redirected in the subfolder with the .htaccess
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^.foo.*$
ReWriteRule .*\.(gif¦jpg)$ - [F]
Also have this is the subfolder .htaccess (to stop it being viewed)
<Files .htaccess>
order allow,deny
deny from all
</Files>
Okay thanks.
I added:
RewriteOptions inherit
to the subdirectory .htaccess file and it inherits what is in the root .htaccess
(There is no .htaccess in any folders between on my system, which for others may complicate the issue, I don't know.)
Tested the subdirectory .htaccess (by changing the browser user agent and adding a badbot HTTP_USER_AGENT in the root .htaccess) and it seems to be working fine.
Thanks again.