服务器配置


apache与nginx优雅屏蔽svn与git目录

apache:

在httpd.conf文件中增加:index.php可更换为站点具体页面
也可以解决站点配置文件在vhosts目录下的情况。

<DirectoryMatch .*\.svn|.git|_svn/.*>
RewriteEngine On
RewriteRule ^(.*)(\.svn|.git|_svn)(/.*)$ /index.php [R=301]
</DirectoryMatch>

nginx:
在nginx.conf中增加:

location ~  ^(.*)\/\.svn|.git|_svn\/{
       rewrite ^(.*)(\.svn|.git|_svn)(/.*)$ /index.php  break;
}

nginx静态资源server配置

server
{
    listen    80;
    server_name   img.ename.cn;
    root  /var/www/ename/common_img/;
    index index.html;
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css|ico)$
    {
        access_log off;
        expires 30d;
    }
    access_log  /usr/local/nginx/logs/common_img_access.log;
    error_log  /usr/local/nginx/logs/common_img_error.log;
}
Last Updated:
Contributors: huangyanfu