简体   繁体   中英

Htaccess file redirects wrong ip's

I'm trying to redirect spam ip's from my website to a different website.

For some reason the following code in my .htaccess file redirects me (my ip) to the www.underconstruction.com despite my ip not being included. My ip has the following format 5.64...

Please, could you help me improve the following code so that it redirects only the listed ip's / ip ranges to www.underconstruction.com

RewriteEngine On
RewriteCond %{REMOTE_ADDR} ^88\.208\.201\.208 [OR]
RewriteCond %{REMOTE_ADDR} ^209\.190 [OR]
RewriteCond %{REMOTE_ADDR} ^209\.51 [OR]
RewriteCond %{REMOTE_ADDR} ^5\.101 [OR]
RewriteCond %{REMOTE_ADDR} ^62\.210 [OR]
RewriteCond %{REMOTE_ADDR} ^62\.212
RewriteRule ^/* http://www.underconstruction.com/ [L]

Have you checked your error log? Try to use REMOTE_HOST instead of REMOTE_ADDR

The problem can be solved by using the following code in the .htaccess file. The REMOTE_HOST parameter has been used instead of the REMOTE_ADDR

RewriteEngine On
RewriteCond %{REMOTE_HOST} ^88\.208\.201\.208 [OR]
RewriteCond %{REMOTE_HOST} ^209\.190 [OR]
RewriteCond %{REMOTE_HOST} ^209\.51 [OR]
RewriteCond %{REMOTE_HOST} ^5\.101 [OR]
RewriteCond %{REMOTE_HOST} ^62\.210 [OR]
RewriteCond %{REMOTE_HOST} ^62\.212
RewriteRule ^/* http://www.underconstruction.com/ [L]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM