atom feed1 message in[Httpd Wiki] Update of "HtaccessGotch...
FromSent OnAttachments
Apache WikiDec 21, 2007 2:11 pm 
Subject:[Httpd Wiki] Update of "HtaccessGotchas" by noodl
From:Apache Wiki (
Date:Dec 21, 2007 2:11:09 pm

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Httpd Wiki" for change

The following page has been changed by noodl:

The comment on the change is: Wrong and somewhat pointless

------------------------------------------------------------------------------ + deleted - ## page was renamed from ScratchPad/htaccessGotchas - ## page was renamed from htaccessGotchas

- (!) Consider adding these to the main htaccess wiki page currently here -->
[:Htaccess] (!) - - There are a couple of things you must write differently when using .htaccess
instead of main configuration files. Here's a listing. - - === .htaccess location === - When you enable .htaccess files for a certain directory, with AllowOverride,
then for that directory and all subdirectories of that directory, the
AllowOverride will apply. This is probably what you expected, so nothing wrong
with that. However, when looking for a .htaccess file, apache will look for a
file in the directory you access, but it will look for .htaccess files in its
parents, too! - - Examples: - - {{{ - <VirtualHost *:80> - ServerName - DocumentRoot /var/www/example/ - - <Directory /var/www/example/> - AllowOverride All - </Directory> - </VirtualHost> - }}} - - This will allow you to put use .htaccess files on content inside the
/var/www/example/ directory (ie: on the site). This applies
to /var/www/example/images/ or too, for example. - - On the other hand, when you access, apache will
look for .htaccess files in these locations in the following order: - 1. /var/www/example/images/.htaccess - 1. /var/www/example/.htaccess - 1. /var/www/.htaccess - 1. /var/.htaccess - 1. /.htaccess - - === RewriteRules === - The part given as argument to a RewriteRule is stripped from the trailing /,
so, if you have a rule like - {{{ - RewriteRule ^/images/foo.png$ /images/oldfoo.png - }}} - working in your main config file and suddenly it stops working when you moved
to a shared hosting and placed it in a .htaccess, try stripping the first /,
thus becoming - {{{ - RewriteRule ^images/foo.png$ /images/oldfoo.png - }}} - This happens because .htaccess work in a Directory context (thus the same
would have to be done if the rule was in a <Directory> section) - - (Add the RewriteBase considerations!) -