Answer the question
In order to leave comments, you need to log in
How to redirect a domain alias to a specific page in the main domain in Nginx?
Added an alias to the main domain, the task is to redirect the alias to a specific page of the main domain.
server
{
listen 443 ssl http2;
server_name domain.ru;
ssl_certificate /etc/letsencrypt/live/sexyou.cyou/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/sexyou.cyou/privkey.pem; # managed by Certbot
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
ssl_prefer_server_ciphers on;
ssl_dhparam /var/www/ssl/dhparam.pem;
add_header X-Content-Type-Options nosniff;
server_name alias.domain.ru;
return 301 $ scheme://$host/link/landing$request_uri ;
The problem is that when I access alias.domen.ru , I see domen.ru/link/landing/link/landing/link/landing/link/landing/link/landing/link/landing/link in the address bar /landing/link/landing/link/landing/link/landing/link/landing/link/landing/link/landing/link/landing
Answer the question
In order to leave comments, you need to log in
move alias.domen.ru to a separate server block.
server {
listen 443 ssl http2;
server_name alias.domen.ru;
ssl_certificate ... ;
ssl_certificate_key ... ;
return 301 https://domen.ru/link/landing;
}
if
to avoid looping.if ($host = alias.domen.ru) {
return 301 https://domen.ru/link/landing;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question