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: [email protected]
          Reporter: [email protected]
  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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to