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.
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.
Thank you for answering. I understood. I'm sorry for not reading the documentation carefully.