Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access only from a specific URL? 1

Status
Not open for further replies.

donem

MIS
Mar 28, 2001
54
US
Is there a way to make a directory or even just a page accessible from only a certain URL?

Example:
If i'm on and there is a link on there to (or can I make it so that (or is only accessible if they come from ?
 
very unsafe and not very 'clever' way : just check that history.previous (that returns the previous url, just like if you were hitting 'back' and then asking for its location) is in the 'allowed' list. this is NOT recommanded as it's easy to fool.

safe and smart : set it in your webserver. Allow only certain ip to pass thru your web server. This is even easiest to do, but as it heavily depends on the web server you're using i'd suggest you post the qustion in the appropriate forum (for instance, apache forum if your web server is apache)
 
but if I only allow certain IP addresses, that would mean the IP address of the computer accessing the site, not the IP address of the site the link was on, right?
 
also, is there a script or some html or something to check the history.previous like that?
 
And how easy is it to fake an IP address?

Answer: easy!
 
yes, I know that. so, i guess there is really no way to do this without using users and passwords. oh well. if anyone happens to know, please reply.
 
Already read that one. It doesn't say anything about how to restrict referrers though. I just read it again to make sure. I have read a lot on .htaccess and have found out how to restrict what IP addresses or hosts can access a directory, but that is what IP address or host the request is coming from, not where they were referred from. There will be too many different IP addresses accessing my site for me to restrict it to just them.
 
Yes! That looks like what i'm looking for. I haven't got to try it yet, but it looks good. If anyone else has any suggestions, please reply. But, thank you very much wullie!
 
Ok, I have tried it now and worked on it and everything and I can't get it to work. Can someone else try it and see if they can get it to work? This is what i'm looking for, I just can't get it to work. I am not getting any errors. SSL does work on my server. I can't figure out why it won't work.
 
Yes, I did do that. I tried some other SSI on the same page in the same spot to make sure it worked and the other SSI I tried worked. The SSI you are supposed to use for that is supposed to run the cgi script that comes with it, but it doesn't appear to be doing so. I changed the variables that I was supposed to change. They are all correct. I don't get any errors or anything. I can access the page from anywhere, not just the site I specified.
 
well, the url it would work on is
Here is the first little bit of source on that page:
---------------
<HTML>

<!--#exec cgi=&quot;../cgi-bin/thebouncer.cgi&quot; -->

<HEAD>

<TITLE>Poll</TITLE>

</HEAD>
---------------
However, when you view the source, it just shows a blank space where the ssi tag is. I have tried a ssi tag to show the referer, and that worked fine. But, this one doesn't. Could it be because of the ads or something?

Here is what my thebouncer.cgi script looks like (yes, the path to perl is correct):

#!/usr/bin/perl

######
# The Bouncer by Jimmy (wordx@hotmail.com) for SmartCGIs.com
######
##############
# This is where you want to send people if they are coming from an invalid referrer.

$redirect = '
##############
# These are the URLs from where people are allowed to be coming from (your site).
# If you want people to just come from one page, put # If you want people to be able to come from any page located on a domain, put just # You don't need to include the http:// or the trailing slash (/) in the URL.
# Put as many as you want, seperate them by , and put them inside ' '

@sites = ('
##############################
##############################
# DO NOT edit anything below #
##############################
##
#

print &quot;Content-type: text/html\n\n&quot;;

$referer = $ENV{'HTTP_REFERER'};
if($referer eq &quot;&quot;) { &redirect; }

foreach $site(@sites) {
if($referer =~ /$site/i) { print &quot;&quot;; exit; }
}
&redirect;

sub redirect {
print <<EOF;
<META HTTP-EQUIV=REFRESH CONTENT=&quot;2; URL=$redirect; target=_top&quot;>
<center>
<br><font color=red>You do not have access to this page! You are being redirected...</font><br>
</center>
EOF
exit;
}
 
Ok, here is the results:

1. [an error occurred while processing this directive]
2. same as it was before I changed anything.
3. same as it was before I changed anything.
 
Hi mate,

Are you sure the path to perl is correct and also the permissions are set correctly?

The problem is with the script and not the SSI tag as I am getting an internal error when I try to access the script directly on your server.

Wullie

 
yep, positive it is right. i have other scripts too. they have the same exact path for the perl and they work fine.
 
But what about the permissions?

Try 777 and see if that helps, you don`t have to leave it like that but is worth a try to test the script.

Looks so much like incorrect permissions to me.

That`s all I can think of just now...
Wullie

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top