Forum Moderators: phranque
i got one of my newbie questions again. I have for weeks now somebody from Turkey tinkering with my WP, trying to login 50 times in 2 hours, sign up as admin etc. I see in my logs.
Can I just redirect anybody from this country somewhere with .htaccess or block them?
My htacess looks like this:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!http://www.#*$!#*$!#*$!.com
RewriteRule (wp-content/uploads.*\.(gif¦jpg¦jpeg¦png)$)¦(wp-content/gallery/zzzzzz-mix.*\.(gif¦jpg¦jpeg¦png)$) [#*$!#*$!#*$!xx.com...] [L]
RewriteBase /
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule . /index.php [L]
</IfModule>
I googled some around and found a older post on a forum suggesting this:
RewriteCond %{ENV:TR} ^TR$ [NC]
RewriteRule ^(.*)$ [myredirection.url...] [R,L]
So if I add this everybody from turkey get's send to my redirection.url? I'm not mind blocking complete, just dont know how.... only found the above sample with re-direct.
And to make sure - I would just add this 2 lines below the last 2 above the </ifModule>?
I have also this IP range - is there a better solution with that?
inetnum: 88.251.0.0 - 88.251.127.255
I dont care about traffic from Turkey so no mind to logout somehow...
Thanks for any advise
greetings from La Paz
I'd suggest the following code, inserted above your WP code:
RewriteCond %{REMOTE_ADDR} ^88\.251\.([1-9]?[0-9]¦1[01][0-9]¦12[0-7])$
RewriteRule .* - [F]
Deny from 88.251.0.0/17
mod_rewrite:
RewriteCond %{REMOTE_ADDR} ^88\.251\.([1-9]?[0-9]¦1[01][0-9]¦12[0-7])\.
RewriteRule !^(path-to-custom-403-page\.html¦robots\.txt)$ - [F]
SetEnvIf Request_URI "^/(path-to-custom-403-page\.html¦robots\.txt)$" allowit
Order Deny,Allow
Allow from env=allowit
Deny from 88.251.0.0/17
Jim
thanks for your advise. As said - absolute newbie so to verify -
the way I paste it below? ( replacing the broken pipe of course)
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!http://www.#*$!#*$!#*$!.com
RewriteCond %{REMOTE_ADDR} ^88\.251\.([1-9]?[0-9]¦1[01][0-9]¦12[0-7])$
RewriteRule .* - [F]
RewriteRule (wp-content/uploads.*\.(gif¦jpg¦jpeg¦png)$)¦(wp-content/gallery/zzzzzz-mix.*\.(gif¦jpg¦jpeg¦png)$) [#*$!#*$!#*$!xx.com...] [L]
RewriteBase /
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule . /index.php [L]
</IfModule>
Greetings from La Paz
<IfModule mod_rewrite.c>
#
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
#
# Block IP address range
RewriteCond %{REMOTE_ADDR} ^88\.251\.([1-9]?[0-9]¦1[01][0-9]¦12[0-7])$
RewriteRule .* - [F]
#
# Redirect hotlinked image requests to "nosteal.jpg"
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !http://www\.example\.com
RewriteRule ^wp-content/(uploads¦gallery/zzzzzz-mix)[^.]*\.(gif¦jpe?g¦png)$ http://www.example.com/wp-content/plugins/hotlink-protection/nosteal.jpg [R=302,L]
#
# Rewrite all URL requests that do not resolve to existing files to Wordpress script
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
#
</IfModule>
For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].
Jim
thank you for your time, I used the code as you placed it except replacing the broken pipes....
Yes you right regarding " what if I'm wrong" - I have to take this risk. I come here and ask because I don't know and because I don't have the monetary means to hire a professional. I will not jump on anything I see and try to educate myself on what i read here - and I have some trust.
I asume, considering the amount of posts and the advise you give that you know what you doing and trust it, considering you are human and can make mistakes also - as said I have to take the chances on that.
See, some of the code in this file been created by Wordpress when choosing the permalink option and the file is created - I have / had to trust that also and seen now on differences from your version that it's different/no correct...
Greetings from La Paz