2
  • Laravel 5.5 fresh
  • nginx version: nginx/1.10.3 (Ubuntu)

When I go to: http://<my-ip>/crm/ all is working great, I get the Laravel welcome page, all js and css are loading correctly.

When I go to http://<my-ip>/crm/register - I get 404 for css and js.

This is my conf:

server {
        listen 80 default_server;
        listen [::]:80 default_server;


        root /var/www/html;

        # Add index.php to the list if you are using PHP
        index index.php index.html index.htm;

        server_name _;


        rewrite ^/((?!en)[a-z]*)/home$ /index.php?lang=$1&$args last;
        rewrite ^/((?!en)[a-z]*)/sitemap.xml$ /sitemap.xml last;
        rewrite /pigeon/(.*)$ /pigeon/index.php?/ last;
        rewrite /crm/(.*)$ /crm/index.php?/ last;

        if (!-f $request_filename){
                set $rule_52 1$rule_52;
        }
        if ($rule_52 = "1"){
                rewrite ^/(.*)(?<!php)$ /$1.php last;
        }


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

        location /pigeon {
           alias /var/www/html/pigeon/public;
           try_files $uri $uri/ @pigeon;

          location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_param SCRIPT_FILENAME $request_filename;
            fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
           }
        }


        location /crm {
           alias /var/www/html/crm/public;
                      try_files $uri $uri/ /index.php?$query_string;

        location /crm.(jpg|jpeg|gif|css|png|js|ico|html)$ {
                access_log off;
                expires max;
        }

          location ~ \.php$ {
           include snippets/fastcgi-php.conf;
            fastcgi_param SCRIPT_FILENAME $request_filename;
            fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
           }
        }

How do I fix this conf file to catch css and js files correctly? Thanks

1 Answer 1

0

I had a similar issue. It seems allright what you have there in the server block.Although you might be better off if you add a proper server name. Check this question and see if it helps. It has to do with the symlink to var/www/html for your crm, if you used one.

Laravel 8 + nginx - app.css and app.js resources from public/ not loading - 404 not found

And if not you could still use the online CDN's from bootstrap.Also in the question.

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.