Welcome to Centmin Mod Community
Become a Member

Domains Usage of a Short Domain

Discussion in 'Domains, DNS, Email & SSL Certificates' started by Jimmy, Jun 7, 2016.

  1. eva2000

    eva2000 Administrator Staff Member

    58,916
    12,490
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,122
    Local Time:
    12:48 PM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    it shouldn't be doing that if you just parked domain in server_name of main existing nginx vhost and do not run centmin.sh menu option 2/22 to add that parked domain

    i do same domain parking on centminmod.com for parked domains centmin.sh and centmin.com and all urls work fine

    so as before, please post the contents of /usr/local/nginx/conf/conf.d/maindomain.com.conf and if applicable /usr/local/nginx/conf/conf.d/maindomain.com.ssl.conf wrapped in CODE tags (outlined at How to use forum BBCODE code tags)

     
  2. eva2000

    eva2000 Administrator Staff Member

    58,916
    12,490
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,122
    Local Time:
    12:48 PM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    could also be wordpress not liking that as it has it's own known url, so maybe instead of parking you do need separate sever {} context in your existing main vhost and redirect like Domains - Usage of a Short Domain | Centmin Mod Community instead
     
  3. YuchiRO

    YuchiRO Member

    100
    6
    18
    Jan 12, 2015
    Ratings:
    +8
    Local Time:
    9:48 AM
    5.5.4
    @eva2000 Thanks your help. I follow simple step to do my request. Run centmin option 22 and copy data from old-domain and make return 301. All work but cost alot of time because i have alot of files :(

    last question about noob ask, and sorry my English.

    Code:
    server {
        listen 80;
        server_name old-name;
        return 301 $scheme://new-name.com$request_uri;
    }
    This config will redirect all request from old to new. But how to exclude one folder. I want to access to old-domain/wp-admin.

    Here is my complete config file. I dont use SSL so i dont have :)

    Code:
    # Centmin Mod Getting Started Guide
    # must read http://centminmod.com/getstarted.html
    
    # redirect from non-www to www
    # uncomment, save file and restart Nginx to enable
    # if unsure use return 302 before using return 301
    #server {
    #            listen   80;
    #            server_name old-domain.com;
    #            return 301 $scheme://www.old-domain.com$request_uri;
    #       }
    
    server {
      listen 80;
      server_name old-domain.com www.old-domain.com;
      return 301 $scheme://new-domain.com$request_uri;
     
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    
      # limit_conn limit_per_ip 16;
      # ssi  on;
    
      access_log /home/nginx/domains/old-domain.com/log/access.log combined buffer=256k flush=60m;
      error_log /home/nginx/domains/old-domain.com/log/error.log;
    
      root /home/nginx/domains/old-domain.com/public;
    
      # prevent access to ./directories and files
      location ~ (?:^|/)\. {
       deny all;
      }
    
    location / {
       try_files $uri $uri/ /index.php?$args;
    }
    set $cache_uri $request_uri;
        # POST requests and urls with a query string should always go to PHP
        if ($request_method = POST) {
            set $cache_uri 'null cache';
         }
        if ($query_string != "") {
            set $cache_uri 'null cache';
        } 
        # Don't cache uris containing the following segments
        if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
            set $cache_uri 'null cache';
        } 
        # Don't use the cache for logged in users or recent commenters
        if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
            set $cache_uri 'null cache';
        }
       
    location ~* /(wp-login\.php) {
        limit_req zone=xwplogin burst=1 nodelay;
        #limit_conn xwpconlimit 30;
        auth_basic "Private";
        auth_basic_user_file /home/nginx/domains/old-domain.com/htpasswd_wplogin;   
        include /usr/local/nginx/conf/php.conf;
    }
    
      include /home/nginx/domains/old-domain.com/public/nginx.conf;
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/php.conf;
      include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
      include /usr/local/nginx/conf/vts_server.conf;
    }
    
    
     
  4. eva2000

    eva2000 Administrator Staff Member

    58,916
    12,490
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,122
    Local Time:
    12:48 PM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    you don't need to copy data to the old-domain nor do you need to use centmin.sh menu option 22, option 2 would of been fine, just vhost redirect 301 is enough
    if only you access this, you should be able to setup a ip whitelisting mapping and only do redirect 301 for ips other than your own whitelisted ip in /usr/local/nginx/conf/nginx.conf within http{} server context
    Code (Text):
    geo $wpallowed_ips {
    default 0;
    YOUR_IP_ADDRESS 1;
    }
    

    Then if you want to disable your ip whitelisting, edit your ip line entry from 1 to 0 and restart nginx. If you want to whitelist again, edit from 0 to 1 and restart nginx

    Then adjust the 301 redirect to
    Code (Text):
    server {
      listen 80;
      server_name old-domain.com www.old-domain.com;
    if ($wpallowed_ips = '0') {
      return 301 $scheme://new-domain.com$request_uri
    }
    
    .... rest of vhost contents
    } # closing bracket
    

    restart nginx

    but that whitelists your ip to NOT 301 redirect for entire old-domain.com as i am not sure you can just exclude /wp-admin as wordpress has many other files & directories that /wp-admin may call for stuff?

    301 redirects are permanently cached in your web browser cache unless you test in browser's private/incognito mode. So even after you did these changes, your own ip might get 301 redirected. You can use 302 for temp redirect instead and test in incognito mode. You'd need to clear web browser cache, restart browser etc