Это моя текущая nginx конфигурация для специального хоста:
server {
listen *:80;
server_name example.test;
root /var/www/example;
index index.php index.htm index.html;
access_log /var/log/nginx/example.access.log;
error_log /var/log/nginx/example.error.log;
if ($host ~* www\.(.*)) {
set $host_without_www $1;
rewrite ^(.*)$ $scheme://$host_without_www$1 permanent; #1
#rewrite ^ $scheme://$host_without_www$1request_uri permanent; #2
}
# Rewrite for minify
rewrite ^/min/([a-z]=.*) /min/index.php?$1 last;
# canonicalize codeigniter url end points
# if your default controller is something other than "welcome" you should change the following
if ($request_uri ~* ^(/start(/index)?|/index(.php)?)/?$)
{
rewrite ^(.*)$ / permanent;
}
# removes trailing "index" from all controllers
if ($request_uri ~* index/?$)
{
rewrite ^/(.*)/index/?$ /$1 permanent;
}
# removes trailing slashes (prevents SEO duplicate content issues)
if (!-d $request_filename)
{
rewrite ^/(.+)/$ /$1 permanent;
}
# removes access to "system" folder, also allows a "System.php" controller
if ($request_uri ~* ^/system)
{
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
# unless the request is for a valid file (image, js, css, etc.), send to bootstrap
if (!-e $request_filename)
{
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
# catch all
error_page 404 /index.php;
location / {
root /var/www/example;
rewrite ^/min/([a-z]=.*) /min/index.php?$1 last;
}
location = /robots.txt { access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }
location ~ /\. { access_log off; log_not_found off; deny all; }
location ~ ~$ { access_log off; log_not_found off; deny all; }
location ~ \.php$ {
root /var/www/example;
try_files $uri $uri/ /index.php?$args ;
index index.html index.htm index.php;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param APP_ENV dev;
fastcgi_pass docker-php-fpm:9000;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
}
}
Мои файлы дистрибутива находятся в / var / www/example/templates/dist/, но я хочу переписать запросы для / dist / внутренне в / templates / dist / folder.
Я пробовал что-то вроде этого:
location /dist {
root /var/www/example/templates/dist;
}
безуспешно. По моему индексу я всегда получаю 404. php
Я думаю, это не будет ракетостроение. Может ли кто-нибудь помочь мне с этим? :)