Help limit WordPress comment spam with your .htaccess file

Many spambots will visit wp-comments-post.php directly to comment on your WordPress site instead of actually going through a post. You can combat this type of spam by modify the .htaccess file of your WordPress site with the following code:

Example:

RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} .wp-comments-post.php*
RewriteCond %{HTTP_REFERER} !.*mydomain.* [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]

Note: You will need to replace mydomain with your domain name with no prefix.

Example:

RewriteCond %{HTTP_REFERER} !.*mennosites.ca.* [OR]

Redirecting your website to a new domain

Have you ever needed to move your website to a new domain? This can be a tricky thing to do without breaking all the links to your website that exist in emails, print media, Facebook, or anywhere else on the internet. It is possible to redirect all incoming links with a piece of .htaccess code that will keep all your old links working.

.htaccess Code


RewriteEngine On
RewriteBase /

# New code to redirect from olddomain.com to newdomain.com
# Permanent redirect for caching purposes, also include the query string
RewriteCond %{HTTP_HOST} ^olddomain.com
RewriteRule (.*) http://newdomain.com/$1 [R=permanent,QSA,L]

# New code to redirect from www.olddomain.com to www.newdomain.com
RewriteCond %{HTTP_HOST} ^www.olddomain.com
RewriteRule (.*) http://www.newdomain.com/$1 [R=permanent,QSA,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
              

Note:
Replace olddomain.com with your old domain name, and newdomain.com with your new domain name. This will redirect all links that go to your old domain to your new domain.

Link Examples
http://blocksagencies.ca/insurance-tips/faq/
Takes you too
http://blocksagencies.ca/insurance-tips/faq/

http://blocksagencies.ca/contact-us/
Takes you too
http://blocksagencies.ca/contact-us/