请问Laravel5.3在Nginx1.8.1中只能显示首页,其它所有页面都显示403 Forbidden是什么原因?

2025-03-11 00:48:37
推荐回答(1个)
回答1:

server {
    listen 80;
    server_name xxx;
    root /xxx/public;
    index index.php index.html index.htm;

    location / {
        add_header Access-Control-Allow-Origin *;
        try_files $uri $uri/ /index.php?$args;
    }
    
    location ~ .*\.(php|php5)?$ {
        add_header Access-Control-Allow-Origin *;
        #fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;

    }

    location ~* ^.+\.(gif|jpg|jpeg|png|ico|swf|flv)$ {
            expires 30d;
    }
}

你把xxx换成你自己的路径和域名,试试看