Archive of UserLand's first discussion group, started October 5, 1998.
Re: An answer for Apache newbies
Author: Michael A. Alderete Posted: 11/5/1999; 2:11:40 PM Topic: A question for Apache gurus Msg #: 12762 (In response to 12705) Prev/Next: 12761 / 12763
From looking at your redirect list, I think using .htaccess files is a bad way to go. The main reason that Apache gurus say don't use .htaccess files is because there is a significant performance hit, caused by Apache looking for an .htaccess file in the page's directory and *every* directory above it, until it finds one or it hits the root directory.That is, if the visitor requests the file:
http://www.userland.com/ContentServer/customizing/callbacks.html
Apache will look for an .htaccess file in this order:
$SERVER_ROOT/ContentServer/customizing/.htaccess
$SERVER_ROOT/ContentServer/.htaccess
$SERVER_ROOT/.htaccessOn a Unix system, the file system access is very fast, so the performance hit is only important on high volume sites. But I think scripting.com is one of those sites!
On the Be web site, we turn off looking for .htaccess files with the following directive:
AllowOverride None
Then to handle the fairly large number of redirects that we need to do, we use the mod_alias module, which is not quite as sophisticated as the mod_rewrite module that some were advocating, but is easier to write rules for, and (I think) is faster (because it only handles simpler cases). mod_alias is still pretty sophisticated; I think all of your redirects can be handled by it.
mod_alias is enabled by the following directives (assuming you're using Apache with dynamically loaded modules, the most flexible way to go):
LoadModule alias_module libexec/mod_alias.so
AddModule mod_alias.cThen you can create your aliases and redirects, probably in your VirtualHosts section; here are a few samples from the Be configuration:
# Redirect a page in old section to new site/section
RedirectMatch ^/documentation(.*) http://www-classic.be.com/documentation$1
RedirectMatch ^/aboutbe/jobs.* /jobs# Redirect anything in section to one page
RedirectMatch ^/products/beos_tour.* /action# Redirect one page to another page
Redirect /aboutbe/whatsbe.html http://www.be.com/aboutbe/These are redirects, in that they take the person to a new URL, rather than the one they accessed. You can also do aliases, which make the URL they accessed actually point to another file. To make an alias, just change the "Redirect" portion of the above commands to "Alias".
Redirects are the right way to go if the move is permanent, and you want people to use the new URL. Aliases are the right thing if you want people to use the alias (maybe because it's shorter than the full URL).
Hope this is useful!
P.S. So why would Apache have the .htaccess files if they're bad? When you have a lot of people who need to modify the configuration, and you don't want them all mucking with your httpd.conf file. Normally only one person should be able to touch your httpd.conf file!
It's most useful for ISPs and other hosts which allow people with wildly different needs to have their own directory or virtual host on someone else's server. Each person puts an .htaccess file in their own directory to create their customized file mappings, redirects, permissions, CGI or pre-processing configurations, etc.
If you own the whole host, don't use .htaccess files!
There are responses to this message:
- Re: An answer for Apache newbies, Dave Winer, 11/5/1999; 2:22:27 PM
This page was archived on 6/13/2001; 4:53:22 PM.
© Copyright 1998-2001 UserLand Software, Inc.