关于nginx的Laravel 4.1路由错误404

时间:2014-08-08 03:40:08

标签: php laravel nginx http-status-code-404

我在nginx服务器上遇到laravel路径问题。 它显示" 404未找到"对于所有路线,除了默认路线,与此问题非常相似:nginx configuration for Laravel 4

该问题的解决方案:

server {

    listen  80;
    server_name sub.domain.com;
    set $root_path '/srv/www/htdocs/application_name/public';
    root $root_path;

    index index.php index.html index.htm;

    try_files $uri $uri/ @rewrite;

    location @rewrite {
        rewrite ^/(.*)$ /index.php?_url=/$1;
    }

    location ~ \.php {

        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index /index.php;

        include /etc/nginx/fastcgi_params;

        fastcgi_split_path_info       ^(.+\.php)(/.+)$;
        fastcgi_param PATH_INFO       $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
        root $root_path;
    }

    location ~ /\.ht {
        deny all;
    }

} 

它运行良好,唯一的问题是我需要root_path为/ srv / www / htdocs因为我有其他项目在那里运行。 每当我更改线路时:

set $root_path '/srv/www/htdocs/application_name/public';

为:

set $root_path '/srv/www/htdocs';

问题始于url,例如:localhost / application_name / public / users

0 个答案:

没有答案