How can I restrict visitors to certain areas of a website based on IP address?

I want to create two directories on a website: one is only accessible from certain IP addresses, and the other one available to everyone except those IP addresses. I think that the .htaccess mod_rewrite would work best, but how should I do it?

NachoMahma8 years ago
. You're on the right track. This should help.
MePerson (author)  NachoMahma8 years ago
Thanks. I forgot to mention that I want it to automatically redirect, but that can be done easily in PHP with a if...else statement and the IP variable.
. More than one way to skin that cat. PHP will work. Or you can use the refresh meta. Or mod_rewrite.