0% found this document useful (0 votes)
34 views11 pages

Lecture 8

The .htaccess file provides the ability to customize directory-level configuration for HTTP requests. It contains directives that apply to the specific directory and subdirectories. Common uses include security, customized error responses, redirects, and cache control. CGI programs allow dynamic content generation. The web server collects requests and input, runs the program, collects output, adds headers, and sends the response to the client. Implicit objects like request and response provide data about the request and generate responses. Maintaining state across multiple pages is challenging with HTTP's stateless nature.

Uploaded by

bilbatori
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views11 pages

Lecture 8

The .htaccess file provides the ability to customize directory-level configuration for HTTP requests. It contains directives that apply to the specific directory and subdirectories. Common uses include security, customized error responses, redirects, and cache control. CGI programs allow dynamic content generation. The web server collects requests and input, runs the program, collects output, adds headers, and sends the response to the client. Implicit objects like request and response provide data about the request and generate responses. Maintaining state across multiple pages is challenging with HTTP's stateless nature.

Uploaded by

bilbatori
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 11

Web Programming

Lecture 8

1
.htaccess File
Web Programming – Fall 2010

 It provides the ability to customize for


requests to a particular directory
 The directives in the .htaccess file apply to
that directory and all subdirectories
 Why does this start with a dot?
 In several web servers .htaccess is the
default name of directory-level
configuration files.
.htaccess File
Web Programming – Fall 2010

 Common Usage:
 Security
 Customized error responses (e.g. 404)
 Redirects
 CacheControl: control user agent caching to
reduce bandwidth usage, server load etc.
 Most commands in htaccess are meant to be
placed on one line. Turn off word-wrap

3
.htaccess
Web Programming – Fall 2010

 Redirect /olddirectory/oldfile.html
http://yoursite.com/newdirectory/newfile.html
 ErrorDocument 404 /errors/notfound.html
 IndexIgnore *
 IndexIgnore *.gif *.jpg
 order allow,deny

deny from 123.45.6.7


deny from 012.34.5.
allow from all
 www.javascriptkit.com/howto/htaccess.shtml
 http://httpd.apache.org/docs/1.3/howto/htaccess.html

4
CGI
Web Programming – Fall 2010

 Request is collected by the web server


 The corresponding program is called
 Input is sent through QUERY_STRING
 Output from the program is collected by
the Web server
 Headers are added by the Web server
 Output is sent to the client
CGI
Web Programming – Fall 2010

 Can be written in any language


 CGI is notoriously slow
 The program has to load into memory,
execute, and then pass you the document
 Solutions?
 Keep the process in memory at all times !
 Perl, PHP, ASP, Cold Fusion, JSP
Common Gateway Interface
Web Programming – Fall 2010

#include <iostream>
using namespace std;

int main()
{
cout << "Content-Type:text/html"<<endl;
cout << endl;
cout << "<html><body>";
cout << "Hello";
cout << "</body></html>";
return 0;
}
CGI
Web Programming – Fall 2010

#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
cout << "Content-Type:text/html"<<endl;
cout << endl;
cout << "<html><body>";
cout << "You queried " << getenv("QUERY_STRING");
cout << "</body></html>";
return 0;
}
Implicit Objects
Web Programming – Fall 2010

 Implicit objects are the objects which are


provided to you by default
 Vary with language
 Take architecture into account
 Almost every language has similar
methods
Request and Response
Web Programming – Fall 2010

 Request : GET and POST data


 Response: display result
 Response may or may not be an HTML
page
 Equivalent objects (almost) exist in all
scripting languages
Navigation on Multiple Pages
Web Programming – Fall 2010

 HTTP is a stateless protocol


 Each request is taken separately
 Users think of the web site as an application

Login Check Mail

Log Out

 How can we store a user’s state?

You might also like