防止从apache服务器上载*.bak*.inc文件

防止从apache服务器上载*.bak*.inc文件,apache,apache-config,Apache,Apache Config,是否可以防止人们从am apache目录中看到.bak之类的文件?如果有对url的请求(http://foo.com/bar.bak),最好出现404错误,并阻止任何人上传文件。现在我知道了答案,这里是:其中之一是在httpd.conf中使用RewriteRule塞德里克14秒前编辑 现在我知道了答案,这里是:其中之一是在httpd.conf中使用RewriteRule RewriteEngine On # Turn on the rewriting engine RewriteRule Re

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

现在我知道了答案,这里是:其中之一是在httpd.conf中使用RewriteRule塞德里克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
这样的URL不会工作,也不会
foo/bar

我希望它能帮助某人:)