Forum Moderators: phranque
#AIOWPS_BLOCK_SPAMBOTS_START
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} ^(.*)?wp-comments-post\.php(.*)$
RewriteCond %{HTTP_REFERER} !^http(s)?://mydomain\.com [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule .* http://127.0.0.1 [L]
</IfModule>
#AIOWPS_BLOCK_SPAMBOTS_END
# END All In One WP Security
# 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
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_REFERER} buttons-for-website\.com [NC,OR]
RewriteCond %{HTTP_REFERER} semalt\.semalt\.com [NC,OR]
RewriteCond %{HTTP_REFERER} make-money-online\.7makemoneyonline\.com [NC]
RewriteRule .* - [F,L]
# redirect www to non www domain
RewriteEngine on
RewriteCond %{HTTP_HOST} !^example\.com [NC]
RewriteRule ^/?(.*)$ http://example.com/$1 [L,R=301]
</IfModule>
[edited by: phranque at 8:22 pm (utc) on Dec 23, 2014]
[edit reason] exemplified domain [/edit]
<IfModule.. envelope, but it does need to stay the way it is generated - for whatever reason. <IfModule because either you have it or you don't.besides, the RewriteEngine on line only needs to be there once, before the first rewrite and with many Apache servers it is "on" by default. But it hurts nothing to have it once before your rewrites.
- lucy24
[NC] (no case) flag unless it is an expected format, because it adds work for the server without doing anything. RewriteRule .* - [F,L] RewriteRule ^/?(.*)$ http://example.com/$1 [R=301] RewriteCond %{HTTP_HOST} !^example\.com [NC] RewriteCond %{HTTP_HOST} ^www\. [NC] Although I did say redirects should come first
RewriteRule ^forbidden\.html - [L] Perhaps personal preference, but