Reputation: 835
I am trying to run Laravel4.1 on nginx. It's working fine on localhost:8080/ but when I got to localhost:8080/example I get 404 Not Found Error. This is my nginx configuration:
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;
}
}
}
This is my Laravel code:
Route::get('example', function()
{
return View::make('example');
});
Upvotes: 1
Views: 389
Reputation: 164
You might need to add rewriting, so any URL gets sent back to the front controller...
# 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;
}
Upvotes: 1