
![[Netcraft Web Survey Survey Chart]](http://www.netcraft.com/survey/Reports/199910/overallc.gif)
Laurie, Ben; Laurie, Peter. 1999. 2nd
ed.
Apache: The Definitive Guide. Sebastopol (CA): O'Reilly.
369p.httpd.conf).htaccess).htaccess files.
.htaccess files is read on a per request basis..htaccess
/home/c/s/cscie12/public_html/apache/example/.htaccessErrorDocument 404 /~cscie12/status404.html
status404.html
/home/c/s/cscie12/public_html/status404.html<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML lang="en"> <HEAD> <TITLE> CSCIE12: 404 Not Found </TITLE> <BASE href="http://www.courses.fas.harvard.edu/~cscie12/"> </HEAD> <BODY bgcolor="#ffffff" link="#cc3333" vlink="#996633" background="images/background.gif"> <H1>404 Not Found</H1> <H2>CSCIE12: Introduction to Web Site Development</H2> The resource you requested, <br> <strong><!--#echo var="REQUEST_URI"--></strong><br> cannot be found. <HR> The main areas of the site are:<p> <!--#include virtual="inc/nav.html"--> <HR> <!--#include virtual="inc/footer.html"--> <HR> </BODY> </HTML>
.htaccess files apply to the
directory that contains the .htaccess file and all its
descendants.
Directives within the file,
/home/c/s/cscie12/public_html/.htaccess
would apply to all files within and "under" the public_html
directory for the user cscie12.
Directives within the file,
/home/c/s/cscie12/public_html/assignments/.htaccess
would apply to all files within and "under" the
public_html/assignments directory for the user cscie12.
.htaccess files. Some are not.
ErrorDocument directiveSyntax: ErrorDocument error-code documentContext: server config, virtual host, directory, .htaccess Status: core Override: FileInfo Compatibility: The directory and .htaccess contexts are only available in Apache 1.1 and later. |
Also, the "a" indicator on the Apache Quick Reference
Card indicates that the directive is valid within an
.htaccess file.
AllowOverride directive that determines which directives
within .htaccess files Apache will process. The
Override line that is given for each directive in
the Apache documentation
indicates which configuration directive must be active in order to
use that directive with an .htaccess file.
For the FAS system, the main server configuration file has the following directive in place for users' public_html directories:
AllowOverride FileInfo AuthConfig Limit Indexes Options
ErrorDocument directiveSyntax: ErrorDocument error-code documentContext: server config, virtual host, directory, .htaccess Status: core Override: FileInfo Compatibility: The directory and .htaccess contexts are only available in Apache 1.1 and later. |
For example, if the Rewrite Module
(mod_rewrite) has not been activated, none of the
Rewrite directives will be available to use.
Refer to the Status and Module lines in the documentation for each directive and to the documentation for the specific Apache installation you are using.
mod_access mod_actions mod_alias mod_asis mod_auth mod_auth_dbm mod_autoindex mod_cgi mod_dir mod_env mod_expires mod_headers mod_imap mod_include mod_log_config mod_mime mod_negotiation mod_perl mod_rewrite mod_setenvif mod_so mod_status mod_unique_id mod_userdir mod_usertrack raven_ssl
.htaccess file, the most likely cause of the problem
is incorrect permissions and/or an error in the directive syntax.
.htaccess file
are not set correctly. Just like HTML and image files, the server
must be able to read the .htaccess file. The simplest
way to allow that is to make your .htaccess file
readable by "other".
fas% pwd
/home/j/h/jharvard/public_html
is03:~% ls -l .htaccess
-rw------- 1 jharvard founder 349 Nov 27 00:03 .htaccess
is03:~% chmod o+r .htaccess
is03:~% ls -l ~/public_html/.htaccess
-rw----r-- 1 jharvard founder 349 Nov 27 00:03 .htaccess
.htaccess file will result in a
500 Internal Server Error. In addition, correct usage of a
directive that is not allowed in the .htaccess file
will result in a 500 status code. Whether or not a
directive is allowed depends upon the server configuration file
(httpd.conf; AllowOverride) and the directive itself.
.htaccess files. For example, the file corresponding to the
URL,
http://www.courses.fas.harvard.edu/~cscie12/.htaccess exists
and is readable by the Web server, but if we try to follow the
link, we get a 403 Forbidden response.ls command will not list files or directories that
begin with a '.' (dot). In order to see the
.htaccess file when you do a directory listing, use the
-a (all) option:fas% ls assignments cgi-bin faq images inc index.html instructors lecture schedule.html section syllabus fas% ls -a . .. .htaccess assignments cgi-bin faq images inc index.html instructors lecture schedule.html section syllabus
Files and FilesMatch can
be used within .htaccess files.
Examples:
<Files .htaccess>
Order allow,deny
Deny from all
</Files>
# deny access to any tilde backup files
<Files *~>
Order allow,deny
Deny from all
</Files>
.htaccess file:
ErrorDocument 404 /~cscie12/status404.html
Redirecting client requests can be very useful:
http-equiv attribute of the
<META> element. More
information and examples are provided at
http://www.fas.harvard.edu/~web/tutorial/meta/refresh/.
The recommended method is to do it at the server level.
.htaccess file:
Redirect 302 /~cscie12/dce.html http://www.dce.harvard.edu/ Redirect 301 /~cscie12/presentation http://www.courses.fas.harvard.edu/~cscie12/lecture
Summary``The great thing about mod_rewrite is it gives you all the configurability and flexibility of Sendmail. The downside to mod_rewrite is that it gives you all the configurability and flexibility of Sendmail.'' Welcome to mod_rewrite, the Swiss Army Knife of URL manipulation!`` Despite the tons of examples and docs, mod_rewrite is voodoo. Damned cool voodoo, but still voodoo. '' This module uses a rule-based rewriting engine (based on a regular-expression parser) to rewrite requested URLs on the fly. It supports an unlimited number of rules and an unlimited number of attached rule conditions for each rule to provide a really flexible and powerful URL manipulation mechanism. The URL manipulations can depend on various tests, for instance server variables, environment variables, HTTP headers, time stamps and even external database lookups in various formats can be used to achieve a really granular URL matching. This module operates on the full URLs (including the path-info
part) both in per-server context ( But all this functionality and flexibility has its drawback: complexity. So don't expect to understand this module in it's whole in just one day. This module was invented and originally written in April
1996
|
http://www.courses.harvard.edu/<4 digit catalog
number>
RewriteEngine On
RewriteBase /~cscie12
RewriteCond %{HTTP_USER_AGENT} ^Lynx
RewriteRule ^(index.html)?$ text/
~cscie12/public_html/index2.html
<LINK title="Text-only version"
rel="alternate"
href="http://www.courses.fas.harvard.edu/text/index.html"
media="aural, braille, tty">
index2.html provides the text-only
version as a link:
Introduction to Web Site Development (p1 of 3)
#text-only version
Harvard University, DCE
Fall 1999
CSCIE12
Introduction to Web Site Development
David P. Heitmeyer
_________________________________________________________________
Thanksgiving Holiday: Sections for Wed, 24-Nov and Sat, 27-Nov will
not meet.
Lecture 8: Multimedia and HTTP lecture notes and video are available.
Nov 24, 4:15 PM
Lecture 7: JavaScript lecture notes and video are available.
Nov 17, 3:15 PM
Assignment 5 is available. Due 29-Nov
Nov 15, 4:45 PM
-- press space for next page --
Arrow keys: Up and Down to move. Right to follow a link; Left to go back.
H)elp O)ptions P)rint G)o M)ain screen Q)uit /=search [delete]=history list
|
rwx-----x and
rwx---r-x permissions?
main.html or
overview.html to be the default files returned when a
directory is requested?
www.courses.fas.harvard.edu virtual host has the ability to
generate nicely formatted index pages automatically.
httpd.conf for
www.courses.fas.harvard.edu:
DirectoryIndex index.html /cgi-bin/sfindexer.pl
.htaccess file:
ExpiresActive On
ExpiresByType text/html A3600 # HTML expires in 1 hour
ExpiresByType image/gif A2592000 # GIF expires in 30 days
ExpiresByType image/jpeg A2592000 # JPEG expires in 30 days
ExpiresByType image/png A2592000 # PNG expires in 30 days
ExpiresDefault "now plus 1 day" # types not specified
# expires in 1 day
|
This module controls the setting of the The |
fas% ls -l sendasiam.html.asis -rw----r-- 1 cscie12 courses 344 Nov 28 23:25 sendasiam.html.asis
sendasiam.html.asis file:
Status: 301 Now where did I leave that URL Location: http://www.joe.com/ Content-type: text/html <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN"> <HTML> <HEAD> <TITLE>Lame excuses'R'us</TITLE> </HEAD> <BODY> <H1>Fred's exceptionally wonderful page has moved to <A HREF="http://www.joe.com/">Joe's</A> site. </H1> </BODY> </HTML>