Mike Harrison
08-13-2009, 01:21 PM
I've been using htaccess for a couple of years on the site I built myself. I'm not by any means a 'real' webmaster, with deep knowledge and understanding; only someone dangerous enough to get a site online. The htaccess file I'd been using until recently contained only some redirects, and was working.
But I now need to deny access to my site from a long list of ip addresses (hackers from other countries, I'm told). I've put the ip addresses in, using 'order deny,allow' but some of the ip addresses on the deny list are still able to get through, but I can't figure out why. (The list of code was edited due to excessive length.)
order deny,allow
deny from 58.14.0.0/15
(LIST EDITED HERE)
deny from 222.251.128.0/17
deny from baidu.com
deny from gutzwiller.ch
deny from 163data.com.cn
allow from all
<Files .htaccess>
deny from all
</Files>
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_REFERER} websextreff\.info [NC,OR]
RewriteCond %{HTTP_REFERER} apnic\.net
RewriteCond %{HTTP_REFERER} ns.chinanet.cn\.net
RewriteCond %{HTTP_REFERER} cndata\.com
RewriteCond %{HTTP_REFERER} gddc\.com.cn
RewriteCond %{HTTP_REFERER} public.xa.sn\.cn
RewriteRule .* - [F]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mywebsite\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_HOST} !^www\.mywebsite\.com
RewriteRule (.*) http://www.mywebsite.com/$1 [R=301,L]
Redirect 301 /pageone.htm http://www.mywebsite.com/newpageone.htm
Redirect 301 /pagetwo.htm http://www.mywebsite.com/newpagetwo.htm
Redirect 301 /pagethree.htm http://www.mywebsite.com/newpagethree.htm
Redirect 301 /pagefour.htm http://www.mywebsite.com/newpagefour.htm
Redirect 301 /pagefive.htm http://www.mywebsite.com/newpagefive.htm
Redirect 301 /pagesix.htm http://www.mywebsite.com/newpagesix.htm
Redirect 301 /pageseven.htm http://www.mywebsite.com/newpageseven.htm
Redirect 301 /pageeight.htm http://www.mywebsite.com/newpageeight.htm
Redirect 301 /pagenine.htm http://www.mywebsite.com/newpagenine.htm
Redirect 301 /pageten.htm http://www.mywebsite.com/newpageten.htm
# ----- REALMMAN END -----
NOTE: In my code are several individual ip addresses along with the blocks that should include them. Those individual ip addresses are the ones that were still able to get through. I also added a few individual domain names at the end of the list (seen above), hoping that would work.
I just want to make sure what I have here is in the correct syntax and in the correct order. I've run the code through a free online htaccess syntax validator http://www.lyxx.com/freestuff/002.html and it claims everything is OK, but those pesky ip addresses are still getting through.
If anyone would like to see the unedited code, please let me know (and tell me how to attach it here or send it to you). I appreciate any help anyone can offer.
Thanks.
But I now need to deny access to my site from a long list of ip addresses (hackers from other countries, I'm told). I've put the ip addresses in, using 'order deny,allow' but some of the ip addresses on the deny list are still able to get through, but I can't figure out why. (The list of code was edited due to excessive length.)
order deny,allow
deny from 58.14.0.0/15
(LIST EDITED HERE)
deny from 222.251.128.0/17
deny from baidu.com
deny from gutzwiller.ch
deny from 163data.com.cn
allow from all
<Files .htaccess>
deny from all
</Files>
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_REFERER} websextreff\.info [NC,OR]
RewriteCond %{HTTP_REFERER} apnic\.net
RewriteCond %{HTTP_REFERER} ns.chinanet.cn\.net
RewriteCond %{HTTP_REFERER} cndata\.com
RewriteCond %{HTTP_REFERER} gddc\.com.cn
RewriteCond %{HTTP_REFERER} public.xa.sn\.cn
RewriteRule .* - [F]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mywebsite\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_HOST} !^www\.mywebsite\.com
RewriteRule (.*) http://www.mywebsite.com/$1 [R=301,L]
Redirect 301 /pageone.htm http://www.mywebsite.com/newpageone.htm
Redirect 301 /pagetwo.htm http://www.mywebsite.com/newpagetwo.htm
Redirect 301 /pagethree.htm http://www.mywebsite.com/newpagethree.htm
Redirect 301 /pagefour.htm http://www.mywebsite.com/newpagefour.htm
Redirect 301 /pagefive.htm http://www.mywebsite.com/newpagefive.htm
Redirect 301 /pagesix.htm http://www.mywebsite.com/newpagesix.htm
Redirect 301 /pageseven.htm http://www.mywebsite.com/newpageseven.htm
Redirect 301 /pageeight.htm http://www.mywebsite.com/newpageeight.htm
Redirect 301 /pagenine.htm http://www.mywebsite.com/newpagenine.htm
Redirect 301 /pageten.htm http://www.mywebsite.com/newpageten.htm
# ----- REALMMAN END -----
NOTE: In my code are several individual ip addresses along with the blocks that should include them. Those individual ip addresses are the ones that were still able to get through. I also added a few individual domain names at the end of the list (seen above), hoping that would work.
I just want to make sure what I have here is in the correct syntax and in the correct order. I've run the code through a free online htaccess syntax validator http://www.lyxx.com/freestuff/002.html and it claims everything is OK, but those pesky ip addresses are still getting through.
If anyone would like to see the unedited code, please let me know (and tell me how to attach it here or send it to you). I appreciate any help anyone can offer.
Thanks.