Apache 2.2 with mod_negotiation/mod_rewrite ordering problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello everyone,

This is my first post to the list, so hopefully I am providing everything needed to get started. I am running Apache 2.2.3-4+etch5 (Debian Etch, mpm-prefork version), and I am migrating a site over from an Apache 1.3.34 instance. The site depends on mod_rewrite along with content negotiation when accessing some pages on the site. The problem I seem to be running into is the order in which the content negotiation and rewrite rules are applied between Apache 1.3 and Apache 2.2. Here is the simplified test case I have been able to come up with.

.htaccess file (in the root directory)
----------------------------------------
RewriteEngine   On
RewriteBase     /~justinp/apache2test

# First look for the specified file in the exact location specified.
RewriteCond /home/justinp/public_html/apache2test/$1 -f
RewriteRule (.*) - [L]

# If the file still has not been found, look in the global images/ directory
# (if the path has images/ in it
RewriteRule ^(.*)/images/(.*) images/$2 [L]
----------------------------------------

The rewrite rules above are designed to pull all images from the shared images directory if the file does not exist in the exact location specified. Under normal circumstances, the rule works fine. However, it starts to bump into the content negotiation when a file exists in a subdirectory that starts with "images". For example, I am using the following directory structure and files:


/home/justinp/public_html/apache2test/
/home/justinp/public_html/apache2test/images/
/home/justinp/public_html/apache2test/images/logo.gif
/home/justinp/public_html/apache2test/newdir/
/home/justinp/public_html/apache2test/newdir/index.html
/home/justinp/public_html/apache2test/newdir/images.any.extension

The index.html file simply has an <img src="images/logo.gif"> tag to display an image. Since it's relative, the full URL becomes http://www.domain.com/~justinp/apache2test/newdir/images/logo.gif. If the file "images.any.extension" is NOT present in the newdir/ directory, then the rewrite rule kicks in and maps it over to images/logo.gif under the root. If the file "images.any.extension" IS present, then the content negotiation tries to treat that as the requested file, fails, then returns a 404 error. The log message is below.


[Fri Aug 15 12:56:02 2008] [error] [client x.x.x.x] Negotiation: discovered file(s) matching request: /home/justinp/public_html/apache2test/newdir/images (None could be negotiated).


If I load the exact same page in Apache 1, the rewrite rule happens first and the image is displayed properly. It seems like Apache 2 is applying the content negotiation before the rewrite rules while Apache 1 applies the rewrite rules first, unless I'm missing something else (perhaps some minor config difference between the servers?). If I disable Multiviews in the newdir/ directory in an .htaccess file (Options -MultiViews), the problem goes away (obviously), but content negotiation is disabled.

The only thing that I know of in the config files that relates to content negotiation is below (and the same on the Apache 1 and Apache 2 servers).
----------------------------------------
<Directory /home/*/public_html>
Options Indexes SymLinksIfOwnerMatch IncludesNoExec FollowSymLinks MultiViews
</Directory>
----------------------------------------

What could I be missing? Thanks.

Justin Pasher

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux