Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save KustomDeveloper/e1e7def1e269c5426c0346ba62b0ea64 to your computer and use it in GitHub Desktop.

Select an option

Save KustomDeveloper/e1e7def1e269c5426c0346ba62b0ea64 to your computer and use it in GitHub Desktop.
Restrict Direct Access To Files In Wordpress Using htaccess
Directions: Add this file to the bottom of your htaccess file
# Restrict Direct Access To Files
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^https://(www\.)?backyardriches\.com/ [NC]
RewriteCond %{REQUEST_URI} !hotlink\.(gif|png|jpg|doc|xls|pdf|html|htm|xlsx|docx|mp4|mov) [NC]
RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in.*$ [NC]
RewriteRule .*\.(gif|png|jpg|doc|xls|pdf|html|htm|xlsx|docx|mp4|mov)$ https://backyardriches.com/ [NC]
# END Restrict Direct Access To Files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment