This is an old revision of the document!
Advanced PCN Personal Web Pages
Common Gateway Interface (CGI)
The Common Gateway Interface (CGI) provides an interfacing between external applications with information servers. Unlike the “static” characteristic of a plain HTML file, CGI provides means for an HTML file to “dynamically” change the content via executable external (server-side) files.With CGI, the client can execute a program written in PERL (Practical Extraction and Report Language), C++, C, FORTRAN, TCL, AppleScript, etc., from an HTML file containing an executable tag calling the executable file resides in the server side.
An example is given here to illustrate how CGI works with PERL. In this simple example, an HTML file contains a form that takes inputs from the client side, processes the inputs, then displays the processed data on the same page.
Make sure that your .htaccess file contains the following line:
**Options +ExecCGI**
Access Control
With access control, you may choose to grant access permission to or deny access from a selected domain or a group of domains. Authentication control allows passworded-access control to a particular directory of your web site.
To set up access control to a particular directory of your web site, first you need to have a file named ”.htaccess” (make sure you don't leave out the dot infront of the “htaccess”) resides in the directory of which you wish to control access to.
The .htaccess file should contains the following lines:
<Limit GET> order allow,deny allow from all deny from [domain_name,second_domain_name, etc.] </Limit>
or
<Limit GET> order deny,allow deny from all allow from [domain_name,second_domain_name, etc.] </Limit>
User Authentification
STEP 1. Create a directory (name whatever you want) in your home directory. In this example, I called it “authdir”. This directory will contain the .htpasswd file, which contains the passwords you give to the 'invited'- guests'.
STEP 2. Edit the .htaccess file located in the directory under which all files will required correct password to be accessed. This .htaccess file should contain the following lines:
AuthUserFile /home/your-login/authdir/.htpasswd Authname ByPassword AuthType Basic <Limit GET> require valid-user </Limit>
STEP 3. At your Unix shell command prompt, enter the following:
/usr/local/bin/htpasswd -c ~/authdir/.htpasswd user_name_A
The above line may be repeated as many times as you need to add more users. Make sure to include the -c flag IF YOU CREATE THE FILE .htpasswd FOR THE FIRST TIME. -c flag is not required in subsequent addition of new users.
If you successfully execute the htpasswd command, you will be prompted to enter the password of your 'guest' twice.
Make sure to have the correction protection mode in the authentication-required directory. A suggested protection mode is user-group executable and readable. This example shows a simple password-protected web page. To add additional users, (if, for example, each user who wants to access your protected pages needs their own password, simply run htpasswd again for each username/password pair.
Have fun!
