Bug 50349

Summary: Slash after a file gets ignored and the file is served, should 404 instead.
Product: Apache httpd-2 Reporter: fictive
Component: mod_rewriteAssignee: Apache HTTPD Bugs Mailing List <bugs>
Status: RESOLVED FIXED    
Severity: normal Keywords: FixedInTrunk
Priority: P2    
Version: 2.2.17   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Attachments: The rewrite log. Not word wrapped.
fix init of use_path_info

Description fictive 2010-11-27 14:24:17 UTC
### Problem
Apache serves a file, even though it should serve 404.


### File structure
/.htaccess [FILE]
/testikansio/ [DIR]
/testikansio/tekstitiedosto [FILE]


### .htaccess
RewriteEngine On
Rewritebase /

RewriteCond %{REQUEST_URI} !^/testikansio
RewriteRule ^(.*)$ /testikansio/$1


### GET http://gateway.local.lan/tekstitiedosto
Result: The file is served. [CORRECT]
] (3) [perdir /srv/http/] add path info postfix: /srv/http/testitiedosto -> /srv/http/testitiedosto/
] (3) [perdir /srv/http/] strip per-dir prefix: /srv/http/testitiedosto/ -> testitiedosto/
] (3) [perdir /srv/http/] applying pattern '^(.*)$' to uri 'testitiedosto/'
] (4) [perdir /srv/http/] RewriteCond: input='/testitiedosto/' pattern='!^/testikansio' => matched
] (2) [perdir /srv/http/] rewrite 'testitiedosto/' -> '/testikansio/testitiedosto/'
] (2) [perdir /srv/http/] trying to replace prefix /srv/http/ with /
] (1) [perdir /srv/http/] internal redirect with /testikansio/testitiedosto/ [INTERNAL REDIRECT]
/redir#1] (3) [perdir /srv/http/] add path info postfix: /srv/http/testikansio/testitiedosto -> /srv/http/testikansio/testitiedosto/
/redir#1] (3) [perdir /srv/http/] strip per-dir prefix: /srv/http/testikansio/testitiedosto/ -> testikansio/testitiedosto/
/redir#1] (3) [perdir /srv/http/] applying pattern '^(.*)$' to uri 'testikansio/testitiedosto/'
/redir#1] (4) [perdir /srv/http/] RewriteCond: input='/testikansio/testitiedosto/' pattern='!^/testikansio' => not-matched
/redir#1] (1) [perdir /srv/http/] pass through /srv/http/testikansio/testitiedosto


### GET http://gateway.local.lan/tekstitiedosto/XYZ
Result: The file is served. [WRONG]
] (3) [perdir /srv/http/] add path info postfix: /srv/http/testitiedosto -> /srv/http/testitiedosto/XYZ
] (3) [perdir /srv/http/] strip per-dir prefix: /srv/http/testitiedosto/XYZ -> testitiedosto/XYZ
] (3) [perdir /srv/http/] applying pattern '^(.*)$' to uri 'testitiedosto/XYZ'
] (4) [perdir /srv/http/] RewriteCond: input='/testitiedosto/XYZ' pattern='!^/testikansio' => matched
] (2) [perdir /srv/http/] rewrite 'testitiedosto/XYZ' -> '/testikansio/testitiedosto/XYZ'
] (2) [perdir /srv/http/] trying to replace prefix /srv/http/ with /
] (1) [perdir /srv/http/] internal redirect with /testikansio/testitiedosto/XYZ [INTERNAL REDIRECT]
/redir#1] (3) [perdir /srv/http/] add path info postfix: /srv/http/testikansio/testitiedosto -> /srv/http/testikansio/testitiedosto/XYZ
/redir#1] (3) [perdir /srv/http/] strip per-dir prefix: /srv/http/testikansio/testitiedosto/XYZ -> testikansio/testitiedosto/XYZ
/redir#1] (3) [perdir /srv/http/] applying pattern '^(.*)$' to uri 'testikansio/testitiedosto/XYZ'
/redir#1] (4) [perdir /srv/http/] RewriteCond: input='/testikansio/testitiedosto/XYZ' pattern='!^/testikansio' => not-matched
/redir#1] (1) [perdir /srv/http/] pass through /srv/http/testikansio/testitiedosto


### GET http://gateway.local.lan/testitiedosto/XYZ/
Result: The file is served. [WRONG]
] (3) [perdir /srv/http/] add path info postfix: /srv/http/testitiedosto -> /srv/http/testitiedosto/XYZ/
] (3) [perdir /srv/http/] strip per-dir prefix: /srv/http/testitiedosto/XYZ/ -> testitiedosto/XYZ/
] (3) [perdir /srv/http/] applying pattern '^(.*)$' to uri 'testitiedosto/XYZ/'
] (4) [perdir /srv/http/] RewriteCond: input='/testitiedosto/XYZ/' pattern='!^/testikansio' => matched
] (2) [perdir /srv/http/] rewrite 'testitiedosto/XYZ/' -> '/testikansio/testitiedosto/XYZ/'
] (2) [perdir /srv/http/] trying to replace prefix /srv/http/ with /
] (1) [perdir /srv/http/] internal redirect with /testikansio/testitiedosto/XYZ/ [INTERNAL REDIRECT]
/redir#1] (3) [perdir /srv/http/] add path info postfix: /srv/http/testikansio/testitiedosto -> /srv/http/testikansio/testitiedosto/XYZ/
/redir#1] (3) [perdir /srv/http/] strip per-dir prefix: /srv/http/testikansio/testitiedosto/XYZ/ -> testikansio/testitiedosto/XYZ/
/redir#1] (3) [perdir /srv/http/] applying pattern '^(.*)$' to uri 'testikansio/testitiedosto/XYZ/'
/redir#1] (4) [perdir /srv/http/] RewriteCond: input='/testikansio/testitiedosto/XYZ/' pattern='!^/testikansio' => not-matched
/redir#1] (1) [perdir /srv/http/] pass through /srv/http/testikansio/testitiedosto


### Command: httpd -v
Server version: Apache/2.2.17 (Unix)
Server built:   Oct 21 2010 09:07:26
Server's Module Magic Number: 20051115:25
Server loaded:  APR 1.4.2, APR-Util 1.3.10
Compiled using: APR 1.4.2, APR-Util 1.3.10
Architecture:   32-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=128
 -D HTTPD_ROOT="/etc/httpd"
 -D SUEXEC_BIN="/usr/sbin/suexec"
 -D DEFAULT_PIDLOG="/var/run/httpd/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="/var/run/httpd/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"

Distro: Up-to-date Arch Linux as of 27.11.2010
Apache installed from pacman. Only configuration change was AllowOverride All, RewriteLog and RewriteLevel 9.
Comment 1 fictive 2010-11-27 14:27:33 UTC
Created attachment 26350 [details]
The rewrite log. Not word wrapped.
Comment 2 Eric Covener 2010-11-27 14:43:01 UTC
Since you didn't mention AcceptPathInfo, this probably would have been more appropriate to start life on the users mailing list.
Comment 3 Eric Covener 2010-12-06 23:04:32 UTC
Created attachment 26377 [details]
fix init of use_path_info
Comment 4 Eric Covener 2010-12-07 08:08:35 UTC
http://svn.apache.org/viewvc?rev=1043023&view=rev
Comment 5 Eric Covener 2011-02-08 08:02:35 UTC
backported to 2.2.x in http://svn.apache.org/viewvc?rev=1068255&view=rev