Forum Moderators: mack

Message Too Old, No Replies

.htaccess allow, deny

allowing only ONE IP

         

nirman

1:53 pm on Jul 6, 2003 (gmt 0)

10+ Year Member



I've tried dozens of times. I want to use .htaccess to hide a file from everyone except 1 IP (bravenet.com) so I can use their free 'password gate'.

I've successfully used .htaccess to hide folder directories so I know the procedure for creation, upload and permissions. I don't have any .htaccess files higher up in my directory.

Any ideas?

Thanks,
Nirman

claus

2:08 pm on Jul 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



welcome to WebmasterWorld nirman :)

Bravenet does not use one single IP. Rather, they seem to be using any IP in this range:

65.39.176.0 - 65.39.176.255

This should do the trick:

<Files ~ "very-secret-file\.html">
Order Allow,Deny
Allow from 65.39.176
</Files>

- at least i should think so ;)

/claus

<edit>Just replace "very-secret-file\.html" with your file name. The "\" should be used before any "." in the file name</edit>

<edit2>oh... and you might also want to give your own IP access (if you have a fixed ip) just make an "Allow from" line under the one that is already there and type your full IP after it </edit2>

nirman

2:57 pm on Jul 6, 2003 (gmt 0)

10+ Year Member



Thanks for the lightening reply.

Still no access from the bravenet password gate (URL-http://pub19.bravenet.com/passwd/show.php)
the file is getting an alert:

Forbidden
You don't have permission to access /KC/hidden/digialbum.html on this server.

Here's what I used for the .htaccess file:

<Files ~ "digialbum\.html">
Order Allow,Deny
Allow from 65.39.176
</Files>

How do I find the IP number? Is it easy?

Thanks,
Nirman

claus

4:42 pm on Jul 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To find the IP number you need a host name, ie. this: pub19.bravenet.com

Then you need to make a "DNS Lookup" - there are quite a few tools for that, i personally like this one: [dnsstuff.com...] (although it seems quite complicated at first sight)

The host name pub19.bravenet.com points to another host which is called public19.bravenet.com, which, in turn, has an IP of:

65.39.176.119

If You want this IP to be able to access the file you specified, you can write:

<Files ~ "digialbum\.html">
Order Allow,Deny
Allow from 65.39.176.119
</Files>

or

<Files digialbum.html>
Order Allow,Deny
Allow from 65.39.176.119
</Files>

Both should work in this case, meaning: "if you come from 65.39.176.119 you can view the file 'digialbum.html' otherwise you can not view this file".

Everybody else will get the message:
"Forbidden
You don't have permission to access ..."

You could try placing the .htaccess file in the directory "/KC/hidden/" but this should not be necessary.

One more thing: delete trailing spaces after the lines if you copy and paste, this sometimes can give errors.

/claus

<edit>added some and deleted it again..hmm...</edit>

nirman

8:12 pm on Jul 6, 2003 (gmt 0)

10+ Year Member



Still no luck. I'm going to email bravenet and see if they can give me the IP number. That's the only thing I can think of that's keeping this from working.

Thanks for all your help and information. I really appreciate it.

Nirman

claus

10:11 pm on Jul 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I just took a look at the password gate, as i really did not know what it was. It seems to be a plug-in service to manage usernames and passwords for pages on your site. Well, .htaccess can do that for you, there's no need to use an external service. All that is required is that your host has enabled something called "AuthConfig" - you can simply ask them.

If it's enabled, try searching the WW forum for these terms: "htaccess" "htpasswd" "access restriction" - it's sometimes better to use google and limit the search using "site:www.webmasterworld.com"


Anyway, i discovered what is wrong. The bravenet IP is not calling you at all. In stead, the url you gave above just displays your page in a frame using HTML-code like this:

<frame src="something.php?usernum=xxxxxxxxx&id=yyyyyy" frameborder="0" border="0" framespacing="0">

That means that the IP can not be used here. In stead you must use the referer. It's a little more complicated, but try this in your .htaccess in stead:

SetEnvIf Referer ^http://pub(lic)?19.bravenet\.com/passwd/show\.php$ yes 

<Files ~ "digialbum\.html">
Order Allow,Deny
allow from env=yes
</Files>

This code requires that your server is configured to accept the "SetEnvIf" commands. Your hosting co will know about it, so if it doesn't work, ask them.

Explanation:
The code says that, if the calling page is the one you specified (hostname being either "pub19" or "public19") then a variable is set to the value "yes".

If someone then requires a file called "digialbum.html" from your server, they will only be allowed to see it, if this "yes" is there.

/claus