Skip to content

Instantly share code, notes, and snippets.

View stefanpejcic's full-sized avatar
:octocat:
Live long and may the source be with you

Stefan Pejcic stefanpejcic

:octocat:
Live long and may the source be with you
View GitHub Profile
@stefanpejcic
stefanpejcic / functions.php
Created August 26, 2019 14:09
flush rewrite rules
function my_flush() {
flush_rewrite_rules();
}
add_action(\'init\',\'my_flush\');
@stefanpejcic
stefanpejcic / .htaccess
Created August 29, 2019 10:59
Default WordPress .htaccess file
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L
</IfModule>
# END WordPress
@stefanpejcic
stefanpejcic / .htaccess
Created August 29, 2019 11:05
protect .htaccess
<files ~ "^.*\.([Hh][Tt][Aa])">
order allow,deny
deny from all
satisfy all
</files>
@stefanpejcic
stefanpejcic / .htaccess
Created August 29, 2019 11:07
only access wp-admin with a specific IP
# Limit logins and admin by IP
<Limit GET POST PUT>
order deny,allow
deny from all
allow from xx.xx.xx.xx
</Limit>
@stefanpejcic
stefanpejcic / .htaccess
Created August 29, 2019 11:09
protect specific
<FilesMatch "^.*(error_log|wp-config\.php|php.ini|\.[hH][tT][aApP].*)$">
Order deny,allow
Deny from all
</FilesMatch>
@stefanpejcic
stefanpejcic / .htaccess
Created August 29, 2019 11:10
protect wp-config
<files wp-config.php>
order allow,deny
deny from all
</files>
@stefanpejcic
stefanpejcic / .htaccess
Created August 29, 2019 11:12
protect wp-content
Order deny,allow
Deny from all
<Files ~ ".(xml|css|jpe?g|png|gif|js)$">
Allow from all
</Files>
@stefanpejcic
stefanpejcic / .htaccess
Created August 29, 2019 11:13
protect include-only files
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^wp-admin/includes/ - [F,L]
RewriteRule !^wp-includes/ - [S=3]
RewriteRule ^wp-includes/[^/]+\.php$ - [F,L]
RewriteRule ^wp-includes/js/tinymce/langs/.+\.php - [F,L]
RewriteRule ^wp-includes/theme-compat/ - [F,L]
</IfModule>
@stefanpejcic
stefanpejcic / .htaccess
Created August 29, 2019 11:15
file access
RewriteCond %{REQUEST_URI} !^/wp-content/plugins/file/to/exclude\.php
RewriteCond %{REQUEST_URI} !^/wp-content/plugins/directory/to/exclude/
RewriteRule wp-content/plugins/(.*\.php)$ - [R=404,L]
RewriteCond %{REQUEST_URI} !^/wp-content/themes/file/to/exclude\.php
RewriteCond %{REQUEST_URI} !^/wp-content/themes/directory/to/exclude/
RewriteRule wp-content/themes/(.*\.php)$ - [R=404,L]
@stefanpejcic
stefanpejcic / .htaccess
Created August 29, 2019 11:16
script injection
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|[|%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|[|%[0-9A-Z]{0,2})
RewriteRule ^(.*)$ index.php [F,L]