By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,335 Members | 2,718 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,335 IT Pros & Developers. It's quick & easy.

htaccess alternative

P: n/a
Is there a way to use php as an alternative to htaccess to control access to
my wordpress blog. There are several text files (eg one.txt, 1.txt,
first.txt) on my websites that have approved ip addresses.

The php script would compare the ip address of the user who came to my
website with those in the text files. If there is not a match, the user
gets redirected to www.yahoo.com

If there is a match, the rest of the php script would run and hence the blog
would be displayed.

The thought was to put this piece of code at the top of the main php script
used by wordpress so that everytime someone goes to a wordpress blog page,
this piece of php code would execute to verify that the IP address is
approved.

I do know that IP addresses change, but most of the surfers who have access
to my blog have static ip addresses. I'm sure this will also slow down the
site, but the IP lists are not large.

Thank you in advance for any assistance you can provide.

Jun 15 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
(Joseph wrote:
Is there a way to use php as an alternative to htaccess to control access
to
my wordpress blog. There are several text files (eg one.txt, 1.txt,
first.txt) on my websites that have approved ip addresses.

The php script would compare the ip address of the user who came to my
website with those in the text files. If there is not a match, the user
gets redirected to www.yahoo.com

If there is a match, the rest of the php script would run and hence the
blog would be displayed.

The thought was to put this piece of code at the top of the main php
script used by wordpress so that everytime someone goes to a wordpress
blog page, this piece of php code would execute to verify that the IP
address is approved.

I do know that IP addresses change, but most of the surfers who have
access
to my blog have static ip addresses. I'm sure this will also slow down
the site, but the IP lists are not large.

Thank you in advance for any assistance you can provide.


Hi,

Maybe I am being thick, but I get the impression you just described how to
handle it without .htaccess.

Simple add some code above the 'protected' scripts that checks if the
remote_address (via $_SERVER['REMOTE_ADDR']) is in the list.

What is it we can help you with?
Don't you know how to open and read the file that contains the addresses?
Don't you know how to match the actual IP to the ones in the file?

Regards,
Erwin Moller
Jun 15 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.