0

I have an existing shortlink service with long domain name longname.com/Wsdfsdf . When the visitor clicks this link it redirects to longname.com/order-details/customer-id/3435345345435

Now I have a short domain name like sh.rt and would like every longname.com/* to behave same as sh.rt/*

As a result, when the visitor visits sh.rt/Wsdfsdf it will redirect to longname.com/order-details/customer-id/3435345345435 same as longname.com/Wsdfsdf would.

By doing this, I don't have to create a new server for sh.rt

I tried to add domain names in servername to NGINX config file but the problem could be longname.com has default ssl and sh.rt doesn't have.

my Nginx file is:

include forge-conf/mydomain.com/before/*;


server {
      proxy_connect_timeout       600;
  proxy_send_timeout          600;
  proxy_read_timeout          600;
  send_timeout                600;

    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name .mydomain.com;
    root /home/forge/mydomain.com/public;

    # FORGE SSL (DO NOT REMOVE!)
    ssl_certificate /etc/nginx/ssl/mydomain.com/330472/server.crt;
    ssl_certificate_key /etc/nginx/ssl/mydomain.com/330472/server.key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers '...';
    ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/nginx/dhparams.pem;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

    # FORGE CONFIG (DO NOT REMOVE!)
    include forge-conf/mydomain.com/server/*;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/mydomain.com-error.log error;

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/mydomain.com/after/*;

1 Answer 1

0

Copy of my answer on StackOverflow:

Assuming you want both sites to serve the same content:

server_name ~^longname.com|sh.rt$;

This is likely to result in problems with your SSL-Certificate though but you stated that you didn't want to use a separate server-block. If I were you I would configure this as an extra server-block with the same root-directory.

For additional documentation see:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .