0

是否可以防止人们从 am apache 目录中看到像 .bak 这样的文件?如果有对 url (http://foo.com/bar.bak) 的请求,最好有 404 错误,并阻止任何人上传文件。

4

1 回答 1

0

既然我知道了答案,那就是:其中之一是在 httpd.conf 中使用 RewriteRule。– Cedric 14 秒前编辑 现在我知道答案了,这里是:其中之一是在 httpd.conf 中使用 RewriteRule。

RewriteEngine On # Turn on the rewriting engine RewriteRule

RewriteRule   ^(.*(\.(html|htm|gif|js|jpg|jpeg|php|css)|\/))$    $1  [L,NC]
# do not do anything (no rewriting), but don't execute the next rule
#("NC", tells Apache that this rule should be case-insensitive, and "L" tells Apache not to process any more rules if this one is used.)

RewriteRule   ^.*$    /  [NC,R] # rewrite all the other urls to /

这是主要思想。请根据您的需要修改第一个正则表达式!(因为像这样的网址foo?bar=obu不起作用,也不是foo/bar

于 2011-02-09T09:46:47.970 回答