4

今天我在我的服务器上发现了一个奇怪的东西。我创建了一个 php 文件(test.php)并在其中编写了一些 php 代码。然后我用它来称呼它

http://127.0.0.1/test

并执行了“test.php”!没有 .php 时如何理解运行 test.php ?我的根目录上没有 htaccess 文件来告诉 apache 这样做。我想这可能会导致安全问题。我该如何预防?

我的操作系统是 ubuntu,网络服务器是 Apache2。

4

2 回答 2

7

发生这种情况是因为 MultiViews(它在该目录的“选项”中的某处启用)。

看看这里:http ://httpd.apache.org/docs/current/content-negotiation.html#negotiation了解它的工作原理。

于 2013-03-29T23:55:30.870 回答
3

Check your apache config (/etc/apache2/sites-available/[site_name or default]), it probably contains mod_rewrite instructions, for example:

RewriteEngine on
RewriteBase /
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(([^/]+/)*[^.]+)$ /$1.php [L]

If you comment them out with # and restart apache, accessing /test without specifying extension should no longer work.

于 2012-04-08T09:04:50.900 回答