1. 程式人生 > >nginx限制域名對文件的訪問

nginx限制域名對文件的訪問

nginx 限制域名訪問某一文件

server
{
listen 80;
server_name www.ct1.com www.ct2.com www.ct3.com;
index index.html index.htm index.php default.html default.htm;
root /home/wwwroot/www.ct1.com;

                                 if ( $host != www.ct1.com )    
                                    {
                                              rewrite ^.*login.php$  http://$host/    last;   

                                        }

                                    location  ~ .*\.php$
                                    {
                                         allow all;
                                            include enable-php.conf; 
                                    }

                      location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
                                    {
                        expires    30d;                                     

                                    }

                                  location ~ .*\.(js|css)?$
    {
        expires      12h;
    }

    location ~ /.well-known {
        allow all;
    }

    location ~ /\.
    {
        deny all;
    }

    access_log  /home/wwwlogs/www.ct1.com.log;
}

     }

nginx限制域名對文件的訪問