– Here’s a copy of a .htaccess I’ve used before.
– There rewrite rules for better urls.
– Function to remove www from domain.
– Changed upload settings.
– Restrict access to wp-config.php
– Disable directory browsing
– No access to .htaccess file
– Automatically add UTF-8 chatset to pages
– Make php error log for administration
– Set server admin mail
– GZIP Compression
– Disable server signature display
– Stop SPAM comments from bots.
– WordFence related (Antivirus, Firewall etc.)

[code] # REWRITE RULES
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L] </IfModule>

# REMOVE WWW
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC] RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]

# UPLOAD SETTINGS
php_value upload_max_filesize 20M
php_value post_max_size 20M
php_value max_execution_time 200
php_value max_input_time 200

# RESTRICTß ACCESS TO WP-CONFIG.PHP
<files wp-config.php>
order allow,deny
deny from all
</files>

# DISABLE DIRECTORY BROWSING
Options -Indexes

# DONT TOUCH MY HTACCESS
<files ~ "^.*\.([Hh][Tt][Aa])">
order allow,deny
deny from all
satisfy all
</files>

# AUTOMATICALLY ADD UTF-8 CHARSET TO FILES
<FilesMatch "\.(htm|html|css|js)$">
AddDefaultCharset UTF-8
</FilesMatch>

# PHP ERROR LOG
# Display no errors to users
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
# Log to file
php_flag log_errors on
php_value error_log /error/php_error.log

# SET SERVER ADMIN MAIL
ServerSignature EMail
SetEnv SERVER_ADMIN d@angerfox.com

# GZIP COMPRESSION
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/x-javascript applicatioßn/x-httpd-php
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip

# DENY ACCESS TO .htaccess FILE
<files ~ "^.*\.([Hh][Tt][Aa])">
order allow,deny
deny from all
satisfy all
</files>

# DISABLE SERVER SIGNATURE DISPLAY
ServerSignature Off

# STOP SPAM COMMENTS FROM BOTS
RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} .wp-comments-post.php
RewriteCond %{HTTP_REFERER} !yourdomain.com [OR] RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule (.*) http://%{REMOTE_ADDR}/$ [R=301,L] # 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

# Wordfence WAF
<IfModule mod_php7.c>
php_value auto_prepend_file ‘/var/www/html/wordfence-waf.php’
</IfModule>
<Files ".user.ini">
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
</IfModule>
</Files>

# END Wordfence WAF

[/code]
The following two tabs change content below.
Administrator on Angerfox.com. Main blogger of the site (and the only one right now). Identity remains unknown for those who don't know, but these are my interests of life, perspectives of life and reviews of things i buy.

Latest posts by Adminfox (see all)

Leave a Reply

Be the First to Comment!

Notify of
wpDiscuz
Loading...