2013-12-15 2 views
1

Я пытаюсь запустить Laravel4.1 на nginx. Он работает нормально на localhost: 8080 /, но когда я добрался до localhost: 8080/example, я получаю 404 Not Found Error. Это моя конфигурация Nginx:Laravel 4.1 Конфигурация для nginx на mavericks

http { 

     server { 
      listen  8080; 
      server_name localhost; 

      #charset koi8-r; 

      #access_log logs/host.access.log main; 

      location/{ 
       root /var/www/html/example/public; 
       index index.php; 
      } 

      #error_page 404    /404.html; 

      # redirect server error pages to the static page /50x.html 
      # 
      error_page 500 502 503 504 /50x.html; 
      location = /50x.html { 
       root html; 
      } 

      # proxy the PHP scripts to Apache listening on 127.0.0.1:80 
      # 
      #location ~ \.php$ { 
      # proxy_pass http://127.0.0.1; 
      #} 

      # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 
      # 
      location ~ \.php$ { 
       root   /var/www/html/example/public; 
       fastcgi_pass 127.0.0.1:9000; 
       fastcgi_index index.php; 
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
       include  fastcgi_params; 
      } 

     } 
} 

Это мой Laravel код:

Route::get('example', function() 
{ 
    return View::make('example'); 
}); 

ответ

1

Вам может понадобиться добавить перезаписи, так что любой URL отправляется обратно на фронт-контроллер ...

# Removes trailing slashes 
if (!-d $request_filename) { 
    rewrite ^/(.+)/$ /$1 permanent; 
} 

# Rewrite to index.php unless the request is for an existing file (image, js, css, etc.) 
if (!-e $request_filename) { 
    rewrite ^/(.*)$ /index.php?/$1 last; 
    break; 
} 
Смежные вопросы