6

Im trying to configure nginx to serve laravel and yii project on same domain. My laravel project is working fine. Yii project also working but assets folder on yii project is giving err_aborted not found 404. All js css ... files are not found

server {

server_name mydomain.com;
index index.html index.php;
charset utf-8;
set $base_root /var/www;
# App 1 (main app)
location / {
    root $base_root/telemele/public;
    try_files $uri $uri/ /index.php?$query_string;
    error_log /var/log/nginx/telemele.notice.log notice;
    error_log /var/log/nginx/telemele.error.log error;

    location ~* ^/index\.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME /var/www/telemele/public/index.php;
        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
    }
}

# App 2
location ~* /mahabat {
    alias $base_root/html/backend/web;
    try_files $uri $uri/ /mahabat/index.php?$query_string;

    error_log /var/log/nginx/mahabat.notice.log notice;
    error_log /var/log/nginx/mahabat.error.log error;

    location ~* ^/mahabat/index\.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME /var/www/html/backend/web/index.php;
        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
    }
location ~* \.css|\.js|\.jpg|\.jpeg|\.png|\.gif|\.swf|\.svg|\.tiff|\.pdf$ {
 try_files $uri =404;
 }

location ~ ^/assets/.+\.php(/|$) {
        deny all;
    }
}

# Files
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt  { access_log off; log_not_found off; }

# Error
access_log off;
rewrite_log on;

# Disable .htaccess access
location ~ /\.ht {
    deny all;
}
}

What am i doing wrong? How to make nginx not to abort assets folder files? why it is giving not found?

1 Answer 1

4

There might be a missing .htacces file at the frontend/web directory. If you have the same problem, I recommend you to use this

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

1 Comment

its not on apache, its on nginx sis

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.