Forum Moderators: phranque
1. Redirect a troll (based on IP ranges) to a page that says the servers have crashed, sites are down for awhile.
2. Redirect the handful of visitors from troll's hate pages (referrer) on me to the same "site down" page.
rjwmnews was kind enough to assist and I had it all working just fine while testing, as long as I redirected to google. When I changed it to redirect to my special page, I got the following message:
Too many redirects occurred trying to open “http://www.domain.com/crashed.shtml”. This might occur if you open a page that is redirected to open another page which then is redirected to open the original page.
I'll post my full htaccess file if it would be helpful.
Thanks in advance,
Juls
I'd guess you need to add an exclusion to your rule to *allow* the troublemakers to fetch your "special" pages and any images or other stuff included on them. In general terms:
RewriteCond %{REMOTE_ADDR} ^192\.34\.56\.76$ [OR]
RewriteCond %{REMOTE_ADDR} ^12\.43\.65\.10$ [OR]
RewriteCond %{REMOTE_ADDR} ^10\.19\.1\.253$
RewriteCond $1 !^server_down
RewriteRule ([^.]+)\.html$ /server_down.html [L]
Jim
BTW the poster I mentioned above said you were the king of this stuff. I'd have to say I agree....fast and you flipped on the light switch.
Would it be easier on the server if I did the exclusion, or if I did this: I need to do this on two domains (that share the same server), so I send him from domain to domain.
Like this:
IP in the list, redirect from site1.com to site2.com/server_down.html and vice versa.
Or does it matter?
Thanks so much!
do you see anything wrong with this? (shortened and still includes test IP)
RewriteCond %{REMOTE_ADDR} 72.255.[25..35].* [OR]
RewriteCond %{REMOTE_ADDR} 65.8.[200..235].* [OR]
RewriteCond %{REMOTE_ADDR} 75.0.[30..35].* [OR]
RewriteCond %{REMOTE_ADDR} 24.46.[161..162].*
RewriteRule /* [domain.com...] [L,R]
Yes, what's wrong is that it won't work. The backslashes are not optional, and [0..83] is not valid syntax. From the thread you cited:
I should have mentioned:
62.194.[0..83].* is pseudocode, and not the correct syntax for a SetEnv or deny. The regex posted above by jdMorgan is the correct way to express it.
It is important to remember that regular expressions work on character strings; Regex has no knowledge that the character range [0-9] has any numerical meaning; it simply recognizes that notation to mean "match any character in the range of characters from '0' to '9'".
Therefore, it is rather cumbersome to code for IP address ranges using regular expressions, but it can be done if you are careful.
Taking your ranges as an example:
RewriteCond %{REMOTE_ADDR} ^72\.255\.(2[5-9]¦3[0-5])\. [OR]
RewriteCond %{REMOTE_ADDR} ^65\.8\.(2[012][0-9]¦23[0-5])\. [OR]
RewriteCond %{REMOTE_ADDR} ^75\.0\.3[0-5]\. [OR]
RewriteCond %{REMOTE_ADDR} ^24\.46\.16[12]\.
RewriteRule !^crashed\.shtml$ /crashed.shtml [L]
Replace all broken pipe "¦" characters above with solid pipes before use; Posting on this forum modifes the pipe character.
Jim
This is all way beyond this troll's computer capability, but eventually he'll figure out the sites aren't really down for repairs. But it should buy me some time, in which I'm hoping he'll find someone else to bother. If not, the good news is that he's entirely predictable and has no idea how much information a web surfer gives to the webmaster.
Thank you greatly for such help on this...I'll be able to get those ranges straight now.
Juls
An internal rewrite simply changes the filepath associated with a URL: Instead of serving the content of the 'expected' file indicated in the requested URL, we rewrite the request so that the server serves the content of a different file. No indication is given to the client that this is occurring.
An external redirect is a completely-different matter: Instead of serving the requested content, the server generates an HTTP redirect response, sending a message back to the client (browser, robot, etc.) that the requested content has moved to a different URL provided in that redirect response, and must be requested from that new URL. It is then up to the client to re-request the desired resource from the new URL. So every redirect to a URL on your own site means that a second HTTP request will be needed for the client to receive the requested information. It also means that the client is "aware" of the redirect, and in fact, a browser will change the URL in its address bar when it receives a redirect and begins to re-request the resource, revealing to any attentive user that a redirect is taking place.
I hope that explains it a bit...
Jim