nginx配置tp5的pathinfo模式並隱藏后台入口文件


server {
    listen 2223;
    server_name manage;
    access_log /data/wwwlogs/access_manage.log combined;
    root /data/wwwroot/webroot/manage/public;
    index index.html index.htm admin.php;#默認后台admin.php

    location / {
        if (!-e $request_filename) {
            rewrite ^(.*)$ /admin.php$1 last; #隱藏后台入口文件admin.php
            break;
        }
    }

    location ~ ^(.+\.php)(.*)$ {
        # try_files $uri =404;
        fastcgi_pass unix:/dev/shm/php-cgi.sock; #注意:不同系統,路由不一樣
        fastcgi_index index.php;

        include fastcgi_params;
        fastcgi_split_path_info ^(.+\.php)(\/?.*)$;
        fastcgi_param PATH_INFO $fastcgi_path_info;

        # 強制將某些非法地址交給 index.php 處理
        set $new_fastcgi_script_name $fastcgi_script_name;
        if (!-e $document_root$fastcgi_script_name) {
            set $new_fastcgi_script_name "/index.php";
        }

        fastcgi_param SCRIPT_FILENAME $document_root$new_fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $new_fastcgi_script_name;
    }

    location /nginx_status {
        stub_status on;
        access_log off;
        allow 127.0.0.1;
        deny all;
    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
        if (!-e $request_filename) {
            rewrite ^/(uploads/.*)$ /pic.php?$1 last;
        }
        expires      30d;
    }

    location ~ .*\.(js|css)?$
    {
        expires      7d; # 緩存7天
    }

    location ~ /\.ht
    {
        deny all;
    }
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM