faqts : Computers : Internet : Web Servers : Apache

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

5 of 8 people (63%) answered Yes
Recently 5 of 8 people (63%) answered Yes


I want to block http://www.my-domain.com/cgi-bin/my_program?userid=2 But allow all other userids.

Nov 15th, 2001 15:58
Anthony Boyd, Chris O\'Brien,

Since you're asking about a program you apparently wrote and placed in 
the cgi-bin, simply change your program.  For example, if the program 
is written in PHP, try beginning your code with this:
if ($userid == 2) {
   die("Access denied");
However, if you really have no clue what's going on, you could try the 
following.  First, create an HTML file that basically says "access 
denied" or whatever error page you want the user to see.  Put it on the 
server with the other pages.  Then add this to the httpd.conf file:
RedirectMatch ^/.*userid=2$ http://www.yoursite.com/yourerrorfile.html
This will cause any URL ending with "userid=2" to be redirected to the 
error file you created.  Be sure "yoursite" and "yourerrorfile" are 
changed to be the actual names of your site and error file.