Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

For my website, I have the following apache config:

<VirtualHost _default_:80>

    #.........

    DocumentRoot /var/www/web

    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>

    <Directory /var/www/web/>
            Options FollowSymLinks MultiViews Includes
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>

    #.........

    <Directory "/var/www/web/">
      RewriteEngine On
      # uncomment the following line, if you are having trouble
      # getting no_script_name to work
      RewriteBase /

      # redirect www if necessary
      RewriteCond %{HTTPS} !=on
      RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
      RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

      # we skip all files with .something
      RewriteCond %{REQUEST_URI} \..+$
      # RewriteCond %{REQUEST_URI} !\.html$
      RewriteRule .* - [L]

      #root url
      RewriteRule ^$ index.php [L]

      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d

      # no, so we redirect to our front web controller
      RewriteRule ^(.*)$ index.php [QSA,L]
    </Directory>
</VirtualHost>

Basically, any request on a nonexistent file without dot is redirected to the my front web controller. It seems to work well but I don't understand why I have many of the following lines in the log file:

[Mon Aug 06 12:29:52 2012] [error] [client 188.165.238.151] File does not exist: /var/www/web/webcalendar
[Mon Aug 06 12:29:52 2012] [error] [client 188.165.238.151] File does not exist: /var/www/web/calendar
[Mon Aug 06 12:29:52 2012] [error] [client 188.165.238.151] File does not exist: /var/www/web/webcal
[Mon Aug 06 12:29:52 2012] [error] [client 188.165.238.151] File does not exist: /var/www/web/cal
[Mon Aug 06 12:29:52 2012] [error] [client 188.165.238.151] File does not exist: /var/www/web/install

If I try URLs like http://domain.com/cal or http://www.domain.com/cal, my log shows the error returned by my application, not by Apache:

[Wed Aug 08 09:06:04 2012] [error] [client 82.60.63.56] Action "cal/index" does not exist.

How is it possible that apache returns the error directly without sending the request to my application?

EDIT:

This is the output of apache2ctl -S:

VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
_default_:443          mydomain.com (/etc/apache2/sites-enabled/mydomain-ssl:2)
*:80                   is a NameVirtualHost
         default server mydomain.com (/etc/apache2/sites-enabled/mydomain:1)
         port 80 namevhost mydomain.com (/etc/apache2/sites-enabled/mydomain:1)
Syntax OK

UPDATE:

Here is the log of a request:

211.154.213.122 - - [15/Aug/2012:12:39:45 +0000] [mydomain.com/sid#7f87db86bf40][rid#7f87db6990a0/initial] (3) [perdir /var/www/web/] add path info postfix: /var/www/web/phpMyAdmin -> /var/www/web/phpMyAdmin/scripts/setup.php
211.154.213.122 - - [15/Aug/2012:12:39:45 +0000] [mydomain.com/sid#7f87db86bf40][rid#7f87db6990a0/initial] (3) [perdir /var/www/web/] strip per-dir prefix: /var/www/web/phpMyAdmin/scripts/setup.php -> phpMyAdmin/scripts/setup.php
211.154.213.122 - - [15/Aug/2012:12:39:45 +0000] [mydomain.com/sid#7f87db86bf40][rid#7f87db6990a0/initial] (3) [perdir /var/www/web/] applying pattern '^(.*)$' to uri 'phpMyAdmin/scripts/setup.php'
211.154.213.122 - - [15/Aug/2012:12:39:45 +0000] [mydomain.com/sid#7f87db86bf40][rid#7f87db6990a0/initial] (3) [perdir /var/www/web/] add path info postfix: /var/www/web/phpMyAdmin -> /var/www/web/phpMyAdmin/scripts/setup.php
211.154.213.122 - - [15/Aug/2012:12:39:45 +0000] [mydomain.com/sid#7f87db86bf40][rid#7f87db6990a0/initial] (3) [perdir /var/www/web/] strip per-dir prefix: /var/www/web/phpMyAdmin/scripts/setup.php -> phpMyAdmin/scripts/setup.php
211.154.213.122 - - [15/Aug/2012:12:39:45 +0000] [mydomain.com/sid#7f87db86bf40][rid#7f87db6990a0/initial] (3) [perdir /var/www/web/] applying pattern '.*' to uri 'phpMyAdmin/scripts/setup.php'
211.154.213.122 - - [15/Aug/2012:12:39:45 +0000] [mydomain.com/sid#7f87db86bf40][rid#7f87db6990a0/initial] (1) [perdir /var/www/web/] pass through /var/www/web/phpMyAdmin

Which produces the following error:

[Wed Aug 15 12:39:45 2012] [error] [client 211.154.213.122] File does not exist: /var/www/stmtc/web/phpMyAdmin 
share|improve this question
    
RewriteCond %{REQUEST_URI} \..+$ matches a file with a "." anywhere in the filename (because you haven't anchored the beginning of the expression to anything). So not just .something but also something.png and so forth. Maybe you want /\..+$, which would match antyhing with a "." following a "/". –  larsks Aug 12 '12 at 14:09
1  
What do you see when you turn on verbose logging of rewrite processing? This should show you exactly what's happening. –  larsks Aug 12 '12 at 14:11
    
@larsks thank you for your suggestion, I have enabled rewrite login and will update my question with the result. –  olivierw Aug 13 '12 at 15:08
    
@larsks please see the update in my question –  olivierw Aug 15 '12 at 14:48

2 Answers 2

It is hard to know for sure without seeing your entire config, but on the surface this looks like a variation of the "trailing slash problem". I suspect that with a little analysis and experimentation you may validate this.

In the event it is useful, what is going on with Apache is that a request without a trailing slash or file extension is ambiguous - Apache doesn't know whether the request is for a file resource or for a directory resource. It sees the request, parses it, and looks for the resource on the file system assuming it is a file. If the file isn't there, it'll issue a redirect by adding a trailing slash, on the assumption that it should try the request again, but as directory level request since the file didn't exist.

I realize that this doesn't map totally to your problem description but your rewrites are possibly intervening here and making this process a bit less intuitive than normal.

@larsks suggestion of turning on verbose rewrite logging is a very good one, and should shed some light on what is going on.

share|improve this answer
    
thank you @mcauth I have enabled rewrite login and I will update my question with the result. –  olivierw Aug 13 '12 at 15:10
    
please see the update in my question –  olivierw Aug 15 '12 at 14:48
up vote 0 down vote accepted

Thanks to @larsks suggestion and reading the rewrite logs I understand that the error logged:

File does not exist: /var/www/web/phpMyAdmin

was not for the exact request http://domain.com/phpMyAdmin but for the request http://domain.com/phpMyAdmin/scripts/setup.php. The rewrite rule was not called because of the dot in the file name. So all is normal and work correctly.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.