Join the community today
Become a Member

Domains How can I redirect multiple domains permanently?

Discussion in 'Domains, DNS, Email & SSL Certificates' started by Mrbo, Dec 17, 2019.

Tags:
  1. Mrbo

    Mrbo Member

    112
    7
    18
    Jun 17, 2018
    Ratings:
    +7
    Local Time:
    9:49 PM
    Lets say I have 3 domains that I want to point to new urls, how do I do that the best way?

    For example
    /home/nginx/domains/dev1.mysite.com -> newdomain1.com
    /home/nginx/domains/dev2.mysite.com -> newdomain2.com
    /home/nginx/domains/dev3.mysite.com -> newdomain3.com

    Do I put a redirect file in every separate folder or can I do it from one place?
     
  2. pamamolf

    pamamolf Premium Member Premium Member

    3,857
    378
    83
    May 31, 2014
    Ratings:
    +729
    Local Time:
    5:49 PM
    Nginx-1.17.x
    MariaDB 10.3.x
    You can check the configuration files of each domain and do it there....

    Code:
    /usr/local/nginx/conf/conf.d/
    After your adjustments just restart Nginx...
     
  3. Mrbo

    Mrbo Member

    112
    7
    18
    Jun 17, 2018
    Ratings:
    +7
    Local Time:
    9:49 PM
    I dont know what I did wrong. I edited the file to only include this, but it doesnt work:

    Code:
     server {
     
       server_name dev1.mysite.com www. dev1.mysite.com;
       return 301 https://newurl.com$request_uri;  
     }
     
  4. eva2000

    eva2000 Administrator Staff Member

    45,405
    10,302
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,980
    Local Time:
    12:49 AM
    Nginx 1.19.x
    MariaDB 5.5/10.x
    are newurl.com also hosted on same server ? with own /usr/local/nginx/conf/conf.d/newurl.com.ssl.conf nginx vhosts working already ?
    what errors do you get

    for command
    Code (Text):
    curl -I https://newurl.com
    curl -I https://dev1.mysite.com
    curl -I http://newurl.com
    curl -I http://dev1.mysite.com
    

    your example server_name like you have a space between www. and dev1.mysite.com for 2nd entry too

    when testing 301 redirects, use browser in private incognito session otherwise incorrect 301 redirects get permanently cached in normal browser sessions or use 302 temp redirects until you get them right
     
  5. Mrbo

    Mrbo Member

    112
    7
    18
    Jun 17, 2018
    Ratings:
    +7
    Local Time:
    9:49 PM
    The the new url is hosted on a different server. (And I deleted the vhost on the current server with the script
    /root/tools/wp_uninstall_domain.com.sh )

    This is what I get with curl:

    Code:
    curl -I fs.svenskmb.ml
    HTTP/1.1 403 Forbidden
    Date: Fri, 20 Dec 2019 10:22:46 GMT
    Content-Type: text/html; charset=UTF-8
    Connection: keep-alive
    Set-Cookie: __cfduid=db3fe3b95ce0577sdfh45f543f333aafc1576837366; expires=Sun, 19-Jan-20 10:22:46 GMT; path=/; domain=.svenskmb.ml; HttpOnly; SameSite=Lax
    Cache-Control: max-age=15
    Expires: Fri, 20 Dec 2019 10:23:01 GMT
    Server: cloudflare
    CF-RAY: 5480ed73k8354769-AMS

    And this is what the config file looks like:
    Code:
     server {
     
       server_name fs.svenskmb.ml www.fs.svenskmb.ml;
       return 301 https://fridhemssolskydd.svenskmediabevakning.se$request_uri;  
     }

    This is the response I got for another domain that I delted but didnt create a new config file that redirects:

    Code:
    curl -I https://acta.svenskmb.ml
    HTTP/1.1 301 Moved Permanently
    Date: Fri, 20 Dec 2019 10:19:07 GMT
    Content-Type: text/html; charset=UTF-8
    Connection: keep-alive
    Set-Cookie: __cfduid=dab49f53dusr45d7g734h5739461576837146; expires=Sun, 19-Jan-20 10:19:06 GMT; path=/; domain=.svenskmb.ml; HttpOnly; SameSite=Lax
    X-Redirect-By: WordPress
    Location: https://coconuthostel.org/
    X-Powered-By: centminmod
    X-Xss-Protection: 1; mode=block
    X-Content-Type-Options: nosniff
    CF-Cache-Status: DYNAMIC
    Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
    Server: cloudflare
    CF-RAY: 5480823hf745s59c27-AMS
     
  6. eva2000

    eva2000 Administrator Staff Member

    45,405
    10,302
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,980
    Local Time:
    12:49 AM
    Nginx 1.19.x
    MariaDB 5.5/10.x
    then you need to check the headers for new url too on other server via commands run from your centmin mod server you are doing redirects from run
    Code (Text):
    curl -I https://fridhemssolskydd.svenskmediabevakning.se
    curl -I http://fridhemssolskydd.svenskmediabevakning.se