Laravel routes not found after nginx install

前端 未结 6 792
失恋的感觉
失恋的感觉 2020-12-24 02:17

After I changed ICG to nginx all routes except index page does not work.

Laravel Config:

#/etc/nginx/sites-enabled/laravel
server {
    listen 80;

          


        
6条回答
  •  暖寄归人
    2020-12-24 02:50

    I was also getting the same error of Routes not working on Nginx on my Ubuntu 16.04

    To solve Routes problem, i tried the following code and its just working fine for me.

    Open project conf file using following command

    sudo nano /etc/nginx/sites-available/projectname 
    

    Then do the following changes in this file

    server {
            listen 80;
            listen [::]:80;
    
           root /var/www/project_name/public;
    
           server_name server_name;
    
    location / {
      
                 try_files $uri $uri/ /index.php$is_args$args;
             }
    
    }
    

    Important thing is to change the try_files in location block.

    location / {
          
                     try_files $uri $uri/ /index.php$is_args$args;
                 }
    

提交回复
热议问题