Laravel路线无法正常工作

时间:2014-04-26 13:28:47

标签: laravel laravel-4

我已将laravel.phar内容正确地解压缩到 c:\ www \ laravel

我有两个问题,我认为是相关的。

  • 我必须访问 localhost / laravel / public / 而不是 localhost / laravel / 来获取默认"您已到达。& #34;
  • 如果我在下面标有 1) app / routes.php 中设置了测试,请访问 localhost / laravel / public / testdir 或< em> localhost / laravel / testdir 我从 nginx
  • 收到 404 not found 错误

1)

    Route::get('/testdir', function()
    {
        return 'Working';
    });

路线似乎部分正常工作,因为如果我设置的路线如下 2)并访问 localhost / laravel / public / ,我会看到&#34; Base测试&#34;正确。

2)

    Route::get('/', function()
    {
        return 'Base test';
    });

我的环境细节

  • c:\ www \ laravel项目目录。
  • Laravel 4.1
  • Nginx nginx-1.5.12
  • PHP-27年4月5日-NTS-Win32的VC9 86

Nginx.Conf文件设置

http {

include       mime.types;
default_type  application/octet-stream;

sendfile        on;

keepalive_timeout  65;


server {
    listen       80;
    server_name  localhost;

    location / {
        root   C:/www;
        index  index.php index.html index.htm;
    }

    location ~ \.php$ {
        root           C:/www;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $request_filename;
        include        fastcgi_params;
    }
}

1 个答案:

答案 0 :(得分:1)

您必须更新nginx配置以匹配laravel安装的公用文件夹。

以下是一个让您入门的示例:

http {

    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;


server {
    listen       80;
    server_name  localhost;
    root   C:/www/;

    location / {
        index  index.php index.html index.htm;
    }

    location /laravel/ {
        root   C:/www/laravel/public/;
        index  index.php index.html index.htm;
        try_files $uri $uri/ /index.php?$query_string;

        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $request_filename;
            include        fastcgi_params;
        }
    }

    location ~ \.php$ {
        root           C:/www/;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $request_filename;
        include        fastcgi_params;
    }
}

确保在对配置进行更改后重新启动nginx!

更新

由于我们现在在服务器级别定义了C:/www,所以将根据在服务器级别进行的配置来提供所有内容。 `location / laravel /用它自己的块覆盖它。所有不在/ laravel /下的脚本都将像以前一样工作......

相关问题