• I tried moving a site on a development domain to it’s production domain. I’m running an Ubuntu 18.04 VPS and Nginx 1.14.0

    How I did the move: First I added the correct IP to the new domain in the admin panel for my domain registrar
    I then updated to the correct URL in the WordPress admin dashboard.
    I then ran certbot sudo certbot --nginx -d oslopeace19.no to get the correct certificates for my site.

    But when I tested the site nginx redirects me to the default site instead of the site I set up.

    I’ve debugged for almost a full day, now I’ve removed the HTTPS certs, but I’m still getting the same error. the weird thing is that when I run curl -v http://oslopeace19.no I get the message

    ...
    < X-Redirect-By: WordPress
    ...

    This leads me to think that WordPress is doing something weird here. To try and solve this I’ve set

    define('WP_HOME','http://oslopeace19.no');
    define('WP_SITEURL','http://oslopeace19.no');
    define('RELOCATE', true);

    in wp-config.php and manually verified that the correct URL is set for siteurl and home in the wordpress database.

    Nginx conf:

        server {
        
           listen 80;
             listen [::]:80;
            #Logger
            access_log /var/log/nginx/oslopeace19;
            error_log /var/log/nginx/error_oslopeace19;
            #Sikkerhet
            add_header X-Content-Type-Options nosniff;
            add_header X-Frame-Options SAMEORIGIN;
            add_header X-XSS-Protection "1; mode=block";
            add_header Content-Security-Policy "frame-ancestors 'self'";
            server_tokens off;
            index index.php;
        
            ## Begin - Server Info
            root /var/www/oslopeace19;
            server_name oslopeace19.no;
            ## End - Server Info
        
            ## Begin - Index
            # for subfolders, simply adjust the rewrite:
            # to use <code>/subfolder/index.php</code>
            location / {
                try_files $uri $uri/ /index.php?$query_string;
            }
            ## End - Index
        location = /.user.ini { deny all; }
        
        
        
        
            ## Begin - PHP
            location ~ \.php$ {
                # Choose either a socket or TCP/IP address
                fastcgi_pass unix:/run/php/php7.2-fpm.sock;
                # fastcgi_pass 127.0.0.1:9000;
        
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_index index.php;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
            }
            ## End - PHP
        
            ## Begin - Security
            # deny all direct access for these folders
            location ~* /(.git|cache|bin|logs|backups)/.*$ { return 403; }
            # deny running scripts inside core system folders
            location ~* /(system|vendor)/.*\.(txt|xml|md|html|yaml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
            # deny running scripts inside user folder
            location ~* /user/.*\.(txt|md|yaml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
            # deny access to specific files in the root folder
            location ~ /(LICENSE|composer.lock|composer.json|nginx.conf|web.config|htaccess.txt|\.htaccess) { return 403; }
            ## End - Security
        
        
        }

    Site URL is oslopeace19.no, any suggestions?

    • This topic was modified 6 years, 9 months ago by samvimes. Reason: formatting errors
    • This topic was modified 6 years, 9 months ago by Jan Dembowski.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Is the site at /nb_no/ the undesired default site? It seems there is another server block sending all domain requests to /nb_no/. The WP redirect is from the installation at /nb_no/ changing the oslopeace19.no to oslopeace19.no/nb_no/. The installation at public root is bypassed entirely.

    Dion

    (@diondesigns)

    https://oslopeace19.no/wp-login.php returns the expected result, so your issue is most likely with nginx. (With WordPress, it usually is.) Verify that your WordPress permalink settings have matching rewrite rules in nginx. Perhaps you forgot to change those after you changed the site URL…

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘301 error after moving domain’ is closed to new replies.