473,398 Members | 2,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

htaccess alternative

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
1 4047
(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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: yawnmoth | last post by:
i'm trying to write a php script that will password protect some random directory by creating a .htaccess file, and a password file to accompany the .htaccess file, and it isn't working... ...
1
by: Marko Lahtinen | last post by:
Hello! A part of my website is protected with a .htaccess file. Can I somehow bypass the username/password dialog ?? Can I somehow "hardcode" the authentication name and password in my php-file...
8
by: Joshua Beall | last post by:
Hi All, How do I disable magic quotes via .htaccess? I put the following file in my webroot, but it does not disable magic_quotes_gpc (according to phpinfo(), both the local and master value...
4
by: Ivo | last post by:
Greetings newsgroup, I am moving some php scripts to a new host. While getting to know the server, I ran into a strange problem. If I add a .htaccess file, or more specifically: a .htaccess with...
7
by: John | last post by:
Hello. I want to get this blasted .htaccess file sorted out, so I can have sessions without register_globals being on. I have looked everywhere for info on this and I mean everywhere...
0
by: Stoco | last post by:
I am trying to create a generic interface that will manage various ..htaccess protected directories. In the ideal world, the .htaccess would trigger a cgi script that would take login information...
4
by: Bill | last post by:
Does ASP have a file whose function is similar to .htaccess on Apache? I'm looking to protect subdirectory content.
0
by: Jack Hambabo | last post by:
Hi, I'm searching for a php script that can find out whether the current user (I know _SERVER will give me the name for non-cgi php) has the right to view a specific file. My dream is that I...
1
by: nickyeng | last post by:
I have checked this info from apache website, and i confused with it. Procteing System files it said: To run a really tight ship, you'll want to stop users from setting up .htaccess files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.