You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2022/09/16 02:30:03 UTC

[Bug 66267] New: mod_rewrite returns 403 when a directory with the same name as RewriteRule exists in server's root directory

https://bz.apache.org/bugzilla/show_bug.cgi?id=66267

            Bug ID: 66267
           Summary: mod_rewrite returns 403 when a directory with the same
                    name as RewriteRule exists in server's root directory
           Product: Apache httpd-2
           Version: 2.4.51
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: mod_rewrite
          Assignee: bugs@httpd.apache.org
          Reporter: g.g.satken@gmail.com
  Target Milestone: ---

I added rewrite rule in httpd.conf as below:

```
RewriteEngine on
RewriteRule .* /test/sorry.html
```

When I access to http://myhostname/foo/bar, rewrite rule works as expected.
(Apache returns "[DocumentRoot]/test/sorry.html" no matter which page is
accessed)

However, after creating `/test` directory in my server's root directory,
rewrite rule will not work.


You can reproduce this symptom with the following docker commands:

```
# Pull and run httpd docker image
docker run --rm -d --name test_httpd -p 4000:80 docker.io/httpd:2.4.51

# Append rewrite rule to httpd.conf
docker cp test_httpd:/usr/local/apache2/conf/httpd.conf ./
echo $'LoadModule rewrite_module modules/mod_rewrite.so\nRewriteEngine
on\nRewriteRule .* /test/sorry.html' >> httpd.conf
docker cp ./httpd.conf test_httpd:/usr/local/apache2/conf/httpd.conf

# Create test HTML page
docker exec test_httpd sh -c "mkdir /usr/local/apache2/htdocs/test && echo Test
page > /usr/local/apache2/htdocs/test/sorry.html"
docker restart test_httpd

# This curl command works as expected. (says "Test page" with status 200)
curl http://localhost:4000/foo/bar

# After creating `/test` directory in my root directory in container, apache
returns "403 Forbidden".
docker exec test_httpd sh -c "mkdir /test"
curl http://localhost:4000/foo/bar
docker stop test_httpd
```

This example is a container, but the same thing happens on a normal server.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 66267] mod_rewrite returns 403 when a directory with the same name as RewriteRule exists in server's root directory

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66267

Eric Covener <co...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

--- Comment #1 from Eric Covener <co...@gmail.com> ---
Rewrite guesses that you are rewriting a url path to a filesystem path when the
first segment exists on disk.

When rewiring from url to url, PT is a good way to make it explicit.

This guessing is a historical behavior that is difficult to unwind.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 66267] mod_rewrite returns 403 when a directory with the same name as RewriteRule exists in server's root directory

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66267

Sato Kenta <g....@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |CLOSED

--- Comment #2 from Sato Kenta <g....@gmail.com> ---
Thank you for answering. I understood.
I'm sorry for not reading the documentation carefully.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org