我试图配置nginx服务于同一个域上的laravel和yii项目。我的laravel项目工作正常。Yii项目也工作,但yii项目上的assets文件夹给出err_aborted****找不到404。所有js css ...文件都找不到
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;
}
}
我做错了什么?如何让nginx不放弃资产文件夹文件?为什么它给找不到?
1条答案
按热度按时间dnph8jn41#
frontend/web目录下可能缺少一个.htacces文件,如果你也有同样的问题,我建议你使用this