.htaccess allow from my web server


#1

Hi all,

I’m trying to write a simple .htaccess script to prevent users from viewing contents of a certain directory on my site.

Basically, I need to make this directory accessible by script only.

I know this much:

order deny,allow
deny from all
allow from 123.4.5.6

However, I don’t know the IP address of my server. Or, should I use a domain?

Really appreciate any help.


#2

Couldn’t you just use the loopback address, 127.0.0.1?


#3

No, because the web server isn’t running on 127.0.0.1. (For load distribution reasons, there is actually more than one Apache service running on each shared hosting machine.)

There isn’t really any general answer I can give you, as each web server has more than one IP address, and it’s not always predictable which one it will use, especially to connect to itself like you’re doing. If at all possible, I’d look into what it’d take to run your scripts without getting the web server involved.


#4

If you want to run it only from a script, then why not move it out of webspace and into /home/USER/SCRIPTS?