2

Recently I have Installed Laravel in Nginx. Laravel application home page works fine but route page gets 404 error. My Nginx configuration is below:

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /var/www/html;
    index index.html index.htm index.php;

    server_name localhost;

    location / {
            try_files $uri $uri/ /index.php?$query_string;
            #try_files $uri $uri/ =404;
            #try_files $uri $uri/ /index.php$is_args$args;
    }
    error_page 404 /404.html;

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
            root /var/www/html;
    }


    location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
    }
}

When I access url like localhost/lar/public, it works fine. Routes are declared but when I access URL like localhost/lar/public/test, it gets 404 error.

3
  • Have you properly configured APP_URL in your .env file? Commented Jun 23, 2016 at 16:58
  • Yeah, I have properly configured APP_URL in .env file. But still not works Commented Jun 23, 2016 at 17:07
  • You should set your root to something like root /home/user_name/Documents/laravel_project_name/public; Commented Jun 24, 2016 at 13:36

1 Answer 1

8

Just Changed root to /var/www/html/lar/public, then routes works properly

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.