.htaccess Redirect user when accessing directory uploads

43 Views Asked by At

I need to redirect to the home page example (mysite.com) every time any user accesses any file or the uploads own directory that uploads directory has subdir year> month inside has image files I wanted the user to be redirected to the site home page without external images being broken can anybody help me? any help is welcome. enter image description here

my actual .htacess file

RewriteEngine on

RewriteCond %{QUERY_STRING} (?:^|&)fbclid=

RewriteRule ^ / [L,R=permanent]

<IfModule mod_php4.c>
  php_value engine off
</IfModule>
<IfModule mod_php5.c>
  php_value engine off
</IfModule>

<Files ~ "\.((php[0-9]?)|p?html?|pl|sh|java|cpp|c|h|js|rc)$">
Order allow,deny
Deny from all
</Files>
1

There are 1 best solutions below

3
AudioBubble On BEST ANSWER

try this ;) For jpg,png,gif redirect

RewriteEngine on 

RewriteCond %{HTTP_REFERER} !^https://mysite,com/ .*$ [NC] 
RewriteCond %{HTTP_REFERER} !^https://mysite,com/.*$ [NC] 
RewriteRule \.(jpg|jpeg|png|gif)$ https://mysite,com/  [NC,R,L] // PAGE TO REDIRECT




<IfModule mod_php4.c>
  php_value engine off
</IfModule>
<IfModule mod_php5.c>
  php_value engine off
</IfModule>

<Files ~ "\.((php[0-9]?)|p?html?|pl|sh|java|cpp|c|h|js|rc)$">
Order allow,deny
Deny from all
</Files>