Answer the question
In order to leave comments, you need to log in
How to get rid of the redirect to the root of the domain?
Good afternoon. I can’t figure out how to make it so that when you enter the path https://domain.ru/page in the browser’s get line, nginx does not transfer to the root https://domain.ru , but passes the entire path https://domain.ru to the site /page . Already used $request_uri, but something doesn't work like that.
If the food is like this, it endlessly redirects to the page and in the end just discards
server {
#listen [::]:80;
server_name domen.ru;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/domen.ru/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/domen.ru/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
root /var/www/web/main;
access_log /var/log/nginx/domen.access.log;
error_log /var/log/nginx/domen.error.log;
index index.php index.html index.hml;
location / {
try_files $uri $uri/ /index.php?$args;
#return 301 https://domen.ru$request_uri;
}
# Разрешить использовать шрифты из домена
location ~* \.(eot|ttf|woff|woff2|svg)$ {
access_log off;
add_header Access-Control-Allow-Origin *;
}
location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
access_log off;
expires max;
}
location ~ /\.ht {
deny all;
}
location ~ \.php$ {
fastcgi_index index.php;
fastcgi_keep_conn on;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
#error_page 404 /404.html;
#error_page 403 /403.html;
#error_page 405 =200 $uri;
#error_page 500 502 503 504 /50*.html;
location = /50*.html {
root /usr/share/nginx/html;
}
}server {
if ($host = domen.ru) {
return 301 https://$host$request_uri;
} # managed by Certbot
#listen [::]:80 ipv6only=on;
server_name domen.ru;
return 404; # managed by Certbot
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question