0
Длинный и короткий, я добавил подкаталог моего кода (/ main-site/sub), и я хотел добавить его в мою конфигурацию nginx. Тем не менее, я не могу остановить загрузку поддомена неправильно (some.web.site/sub/sub/index.html) вместо (some.web.site/sub/index.html).Невозможно добавить/загрузить субдомен Nginx (повторы субдоменов)
Вот конфигурационный файл:
server {
listen 80;
server_name site.com www.site.com ~^((?<subdomains>.+)?\.)?site.com$;
root /srv/site;
index index.html index.htm;
access_log /var/log/nginx/site/access.log;
error_log /var/log/nginx/site/error.log;
if ($subdomains !~* "^(www)?$") {
rewrite ^/(.*)$ https://$subdomains.site.com/$1 redirect;
}
rewrite ^/(?!index)(.*).html$ $1 permanent;
rewrite ^/stuff1$ /st1 redirect;
rewrite ^/stuff2$ /st2 redirect;
rewrite ^/stuff3$ /st3 redirect;
rewrite ^/stuff4$ /st4 redirect;
rewrite ^/stuff5$ /st5 redirect;
location/{
# First attempt to serve request as file, then
# as directory, then fall back to 404
# hide html extension
try_files $uri.html $uri/ =404;
}
## Where this stays in or not the result is the same
## site.com/sub/sub/index and not site.com/sub/index
## location /sub/ {
## root /srv/site;
## }
# Redirect 404 to index
error_page 404 = @fallback;
location @fallback {
rewrite .*/permanent;
}
}
Спасибо!