(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Printer Friendly Version



htacess web html


What is this stuff?

If this isn't exactly what you wanted, please try our Search (there's a LOT of techy and non-techy stuff here about Linux, Unix, Mac OS X and just computers in general!):



From - Wed Mar  8 14:43:04 2000
Received: from europe.std.com (europe.std.com [199.172.62.20])
        by aplawrence.com (8.9.3/8.9.3) with ESMTP id GAA20337
        for <tony@aplawrence.com>; Wed, 8 Mar 2000 06:46:52 -0800 (PST)
Received: from world.std.com (root@world-f.std.com [199.172.62.5])
        by europe.std.com (8.9.3/8.9.3) with ESMTP id JAA18598;
        Wed, 8 Mar 2000 09:46:14 -0500 (EST)
Received: from europe.std.com (europe.std.com [199.172.62.20])
        by world.std.com (8.9.3/8.9.3) with ESMTP id JAA24383;
        Wed, 8 Mar 2000 09:42:52 -0500 (EST)
Received: (from daemon@localhost)
        by europe.std.com (8.9.3/8.9.3) id JAA17795
        for web-announce-outgoing; Wed, 8 Mar 2000 09:41:27 -0500 (EST)
Date: Wed, 8 Mar 2000 09:36:38 -0500 (EST)
From: Jonathon Alsop <jalsop@world.std.com>
To: web-announce@world.std.com
Subject: Today on The World Kiosk, Vol. 6 #043, Tuesday, March 7, 2000
Message-ID: <Pine.SGI.3.95.1000308093601.19235A-100000@world.std.com> 
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Sender: web-announce-approval@world.std.com
Precedence: list
Reply-To: web-staff@europe.std.com
Status: U
X-Mozilla-Status: 8001
X-Mozilla-Status2: 00000000
X-UIDL: c29b70cb961166f0362fd074846a7155


===========================================================================
TODAY on The WORLD KIOSK     Vol. 6 #043     Tuesday, March 7, 2000
===========================================================================



        KIOSK: Fun With Your .htaccess File!

-------------------------------------------------------------------------

KIOSK: Fun With Your .htaccess File!

Many Kiosk customers are familiar with the .htaccess file in Apache since
this is one of the files you use to set up password protection of pages
and directories (see http://www.std.com/web/password.shtml for
instructions).  As it turns out, the .htaccess file can do lots of other
useful things too, like specifying custom error pages, assigning
re-directs within the site, turning server-side includes on for files
without the shtml extension, and allowing or denying access based on the
visitor's IP address.

A WORD OF WARNING!  The functionality of .htaccess is very powerful, and
if you set it up wrong, you can very easily open a huge security hole for
yourself or just generally break your web site.  The functions we'll talk
about today are very standard and shouldn't pose any problems, but be
careful anyway!  As my childhood friend's extremely anxious mother used to
say, you can drown in a tablespoon of water, and since we never knew
anyone who had, we knew it was not bad advice.  The few functions we're
talking about today are very standard and shouldn't pose any problems, but
beware of all the things you might discover once you start poking around
the Apache documentation.

GETTING STARTED
First of all, to keep visitors from looking at the contents of your
.htaccess file in their browsers, put this at the top of the file:



<Files .htaccess>
  order allow,deny
  deny from all
</Files>

CUSTOM ERROR RESPONSES
http://www.apache.org/docs/custom-error.html

Assuming you have a directory called /errors and different error files for
each of the most popular errors, use this code to spec out custom
messages:

ErrorDocument 401 /errors/401.shtml
ErrorDocument 403 /errors/403.shtml
ErrorDocument 404 /errors/404.shtml
ErrorDocument 500 /errors/500.shtml

Of course, you can call the directory and the files pretty much whatever
you want.  They do not have to be named 403.shtml and so on.  If you want
the errors to show the same error message each time (/errors/oops.shtml),
set it up like this:

ErrorDocument 401 /errors/oops.shtml
ErrorDocument 403 /errors/oops.shtml
ErrorDocument 404 /errors/oops.shtml
ErrorDocument 500 /errors/oops.shtml

On my site, I have all my errors going through a cgi script called
guardian.cgi that logs the error, generates the error page, and notifies
the administrator, so my file looks like this:

ErrorDocument 401 /cgi-bin/guardian.cgi?401
ErrorDocument 403 /cgi-bin/guardian.cgi?403
ErrorDocument 404 /cgi-bin/guardian.cgi?404
ErrorDocument 500 /cgi-bin/guardian.cgi?500

You can download and install the Guardian script for free at
http://www.xav.com/scripts/guardian/ as well.

REDIRECTS
Once I started running this Guardian script, I saw that I was still
getting hits to non-existent files from old links that are out there.  To
redirect these hits to existing files, use this syntax:

Redirect 302 /oldfilename http://www.yourdomain.com/newfilename

I have a bunch of links out in the cyber-ether to html files that are now
shtml files as well as files that have been renamed, so my file looks like
this:

Redirect 302 /index.html http://www.invinoveritas.com/index.shtml 
Redirect 302 /ivv.html http://www.invinoveritas.com/index.shtml
Redirect 302 /ivv_95.html http://www.invinoveritas.com/index.shtml
Redirect 302 /mmedia.html http://www.invinoveritas.com/index.shtml
Redirect 302 /snd_agre.html http://www.invinoveritas.com/publish
Redirect 302 /sub_rate.html http://www.invinoveritas.com/index.shtml
Redirect 302 /tastings.html http://www.invinoveritas.com/tastings.shtml

As you see, you can do as many of the redirects in the .htaccess file as
you need.

TURNING ON SERVER-SIDE INCLUDES FOR HTML FILES
The way The World is set up, pages that use server-side includes have to
have the .shtml extension, but you can tell your web site to use SSI for
.html files as well.  (A thousand apologies to at least two customers I
know of who re-named their files before I understood this.)  Here's the
syntax:

AddHandler server-parsed .html

RESTRICTING ACCESS BASED ON IP ADDRESS
http://www.apache.org/docs/mod/mod_access.html

Let's say you've got an office in Seattle with a dedicated connection and
its own static IP address.  You can create your own Intranet so that only
people connecting from that IP address can have access to the site or
parts of the site.  Using this syntax, you can set it up so that multiple
IP addresses have access:

order deny,allow
deny from all
allow from 123.45.678.0 123.45.678.1 123.45.678.2

You can also do this for full and partial IP addresses and full and
partial domain names.

Any questions, please contact us at kiosk@world.com or 617-739-0202, and
we'll help you work through this.

(jalsop)

==========================================================================
[] Send suggestions for tips & URLs to today@world.std.com.
   We're also collecting links for our Web pages at eyeguy@world.std.com.
[] To contact THE WORLD KIOSK, send mail to kiosk@world.std.com or
        call 617-739-4927.  
[] To contact CUSTOMER SUPPORT, send mail to support@world.std.com or
        call 617-739-0202.  
[] To subscribe to the "Today" mailing list, send a note saying 'subscribe
   announcements' to majordomo@world.std.com.
   Subscriptions to this mailing list are open to World customers only.
 [] TODAY ON THE WORLD is (c) copyright 2000 by Software Tool & Die.
   Its contents may freely be redistributed as long as credit is given.






Click here to add your comments



Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments


If you want a picture to show with your comment, go get a Gravatar



/Bofcusm/307.html copyright 1997-2004 (various authors) All Rights Reserved

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

Jump to Comments



Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.

Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.

We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.



More:
       - OSR5
       - Bofcusm


Unix/Linux Consultants

Skills Tests

Guest Post Here











My Favorites

Change Congress