开发者

Unexpected mod_rewrite behaivor

开发者 https://www.devze.com 2023-03-10 14:56 出处:网络
I have a .htaccess file 开发者_开发问答with (only) the following lines: RewriteEngine on RewriteRule (.*)/[^/]+\\.txt$ a.html [L]

I have a .htaccess file 开发者_开发问答with (only) the following lines:

RewriteEngine on
RewriteRule (.*)/[^/]+\.txt$ a.html [L]

What this does is to redirect every URL one directory below the current and ending with .txt.

I have two additional files (each containing one line of text for identification):

  • a.html
  • existent

I have no file named nonexistent.

  • When I request nonexistent/some.txt I get the contents of a.html, as EXPECTED
  • When I request existent/some.txt I get the contents of a.html, as EXPECTED
  • When I request a.html/some.txt I get a 404 error which was UNEXPECTED

Nothe that I don't have dontent-negotiation enabled. To prove this: existent/some.html return 404.

I am totally baffled by this behavior, I'd like to know what principle is working here.


Perhaps add in (untested):

RewriteCond ${REQUEST_URI} !/?a\.html

0

精彩评论

暂无评论...
验证码 换一张
取 消