0

I have just played with Laravel some hours ago and seemed to hit a wall. I have seen similar questions here but they're about Apache

Route::get('/', function()
{
return 'hello world';
});

The routing above worked perfectly for localhost/helloworld/public/, however when I changed to this

Route::get('about', function()
{
return 'this is about';
});

and I used this url localhost/helloworld/public/about, it kept displaying 404 Not Found. Even when I tried localhost/helloworld/public/index.php/about, it still didn't work.

This is my nginx default.conf And this is my .htaccess

I have heard about enabling mod_rewrite on nginx but have't got a clue how to do that.

Please help. Thank you in advance.

Hoang Lam
  • 434
  • 1
  • 8
  • 24

1 Answers1

1

Refrence taken from here

This is an NGINX Configuration i've used with Laravel 4 and Laravel 4.1 that works.

server {

    listen  80;
    server_name sub.domain.com;
    set $root_path '/var/www/html/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;
    }

}
Community
  • 1
  • 1
Guns
  • 2,678
  • 2
  • 23
  • 51
  • so strange, adding `try_files $uri $uri/ @rewrite; location @rewrite { rewrite ^/(.*)$ /index.php?_url=/$1; }` gave me "File not found." – Hoang Lam May 08 '14 at 04:18