Skip to content

Instantly share code, notes, and snippets.

@Horttcore
Created February 15, 2020 19:39
Show Gist options
  • Save Horttcore/f6a06f37add7b84e801ce9eb41f13bc5 to your computer and use it in GitHub Desktop.
Save Horttcore/f6a06f37add7b84e801ce9eb41f13bc5 to your computer and use it in GitHub Desktop.
Protect WordPress folders and contents
# PROTECT WORDPRESS FOLDERS AND CONTENTS.
RewriteCond %{REQUEST_URI} /wp-admin/
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_URI} \.php$ [NC]
RewriteCond %{REQUEST_URI} !/wp-admin/(load-styles|admin-ajax)\.php$
RewriteCond %{HTTP:Cookie} !wordpress_logged_in_.+
RewriteRule .* - [G,L]
RewriteCond %{REQUEST_URI} /wp-includes/
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_URI} \.php$ [NC]
RewriteCond %{REQUEST_URI} !/wp-includes/js/tinymce/wp-tinymce\.php$
RewriteCond %{HTTP:Cookie} !wordpress_logged_in_.+
RewriteRule .* - [G,L]
RewriteCond %{REQUEST_URI} /wp-content/
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_URI} !\.((s?c|le)ss|js(on(p)?)?|gif|ico|jpe?g?|png|svgz?|tiff?|avi|mp(3|4|(e|g)|eg)|eot|otf|tt(f|c)|woff2?)$ [NC]
RewriteRule .* - [G,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment