How to Change Wordpress Homepage url from IP Address to the Domain Name in Features and Ideas

edited November 13 in Features and Ideas
I have installed one click wordpress on vultr. Then, migrated my website from shared hosting to vultr.

I have changed my wordpress URL and Site URL from wordpress setting > General to my domain name.

I have installed let's encrypt ssl certificate. And redirected http urls to https urls. All pages and posts open with ssl and have no problem.

Every thing is OK for all pages except the homepage. The homepage url is still direct to the IP address and not to the domain name. The url of my homepage is https//:IP address and give (Your connection is not secure).

Any ideas on how to change the homepage url from IP address to the domain name.

Comments

  • Log into your WordPress Dashboard & navigate to Settings. What's listed as your Site URL & Home URL?
  • edited November 14
    I have already mentioned above that I have changed my wordpress Site URL & Home URL from wordpress dashboard setting > General to my domain name.

    Every thing is OK with all site. Typing domain name in the web browser directs to https secure connection. Also, typing the IP address directly on the web browser redirect to domain name and https secure connection.

    The only problem is that when I press in the internal homepage button in the website, it directs to (https//:IP address) URL and give (Your connection is not secure).
  • edited November 14

    1). do you update your server_name attribute in the Nginx site configuration files?

    vim /etc/nginx/conf.d/wordpress_http.conf
    # Change the server_name underscore "_" to your domain name.

    vim /etc/nginx/conf.d/wordpress_https.conf
    # Change the server_name underscore "_" to your domain name.

    Reload Nginx:
    systemctl restart nginx.service

    if yes, show me your configuration file.

    2). check if siteurl and home keys in wp_options table in your database are correctly set.

    3) if the problem persists, add this configuration to your wp-config.php file:

    define( 'WP_SITEURL', 'https://example.com' );
    define( 'WP_HOME', 'https://example.com' );

    It will override any values in database.
  • edited November 15
    @ qoraiche , thanks for your reply and help.

    Yes, I have updated the server_name attribute in the Nginx site configuration files and changed the the server_name underscore "_" to my domain name before installing Let's encrypt.

    And I have reloaded Nginx.

    Here is the configuration file: (/etc/nginx/conf.d/wordpress_http.conf)

    upstream php-handler-http {
    server 127.0.0.1:9000;
    #server unix:/var/run/php5-fpm.sock;
    }

    server {
    if ($host = www.onlinebuyguide.com) {
    return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = onlinebuyguide.com) {
    return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($scheme = http) {
    return 301 https://$server_name$request_uri;
    }


    listen 80 default_server;
    server_name onlinebuyguide.com www.onlinebuyguide.com;
    #server_name wordpress.example.com;

    root /var/www/html/;
    index index.php;

    # set max upload size
    client_max_body_size 2G;
    fastcgi_buffers 64 4K;

    access_log /var/log/nginx/wordpress_http_access.log combined;
    error_log /var/log/nginx/wordpress_http_error.log;

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




    And here is the configuration file (/etc/nginx/conf.d/wordpress_https.conf) file

    upstream php-handler-https {
    server 127.0.0.1:9000;
    #server unix:/var/run/php5-fpm.sock;
    }

    server {
    listen 443 ssl default_server;
    server_name onlinebuyguide.com www.onlinebuyguide.com;
    #server_name wordpress.example.com;
    ssl_certificate /etc/letsencrypt/live/onlinebuyguide.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/onlinebuyguide.com/privkey.pem; # managed by Certbot

    root /var/www/html/;
    index index.php;

    # set max upload size
    client_max_body_size 2G;
    fastcgi_buffers 64 4K;

    access_log /var/log/nginx/wordpress_https_access.log combined;
    error_log /var/log/nginx/wordpress_https_error.log;

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

    location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
    }

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


    location ~* \.(htaccess|htpasswd) {



    2). check if siteurl and home keys in wp_options table in your database are correctly set.

    I had previously tried to change Home url from Mysql using some tutorials but it gives me (wp_options table not found). I viewed the tables in Mysql and there is no table with the name (wp_options).



    3) if the problem persists, add this configuration to your wp-config.php file.

    I don't know where to find wp-config.php file and I don't know how to create it.

    And I have read that this file don't exist by default. So, there would be no (wp-config.php) file.


    I think the problem is because I installed one click wordpress using my IP address before pointing the domain name to the server.


    Any idea to solve this issue?
  • Hi again,

    `wp-config.php` is located in your wp installation root directory, it's an important configuration file for WordPress!

    connect to your server with SSH, and edit the config file with the following:

    nano /var/www/html/wp-config.php

    then add the following configuration variables just bellow `/* That's all, stop editing! Happy blogging. */`:

    define( 'WP_SITEURL', 'https://example.com' );
    define( 'WP_HOME', 'https://example.com' );
  • Hello dear,

    Thank you for your replies.

    that doesn't work.

    I have done what you said, but the same problem still exists.


    Here is copy of the modification I did in the var/www/html/wp-config.php


    $table_prefix = 'wp_';
    define( 'FORCE_SSL_ADMIN', false );
    /* That's all, stop editing! Happy blogging. */
    define( 'WP_SITEURL', 'https://onlinebuyguide.com' );
    define( 'WP_HOME', 'https://onlinebuyguide.com' );
    /** Absolute path to the WordPress directory. */
    if ( ! defined( 'ABSPATH' ) )
    define( 'ABSPATH', dirname( __FILE__ ) . '/' );
    /** Sets up WordPress vars and included files. */
    require_once ABSPATH . 'wp-settings.php';

  • I just access to your site:https://onlinebuyguide.com/ and it does not redirect to server IP address, maybe you need to clear your cache!
  • edited November 15
    I told you every thing is OK.

    The only problem is that when I press in the internal homepage button in the website, it directs to (https//:IP address) URL and give (Your connection is not secure).

    That means after accessing the website, if you click in (Home) button which is (الرئيسية in Arabic), it directs to the IP address.

    That means if a visitor landed to any page in the website, and then desired to come back to the Home page and press on (HOME) or (الرئيسية), he will be directed to (https://95.179.165.242) and get connection is not secure.

    Other than that, even if you type the IP address alone on the web browser, you will be redirected to domain name and get secure connection without any problem.

    Also, if you type (http://95.179.165.242) in the web browser, you will be redirected to the domain name and get secure connection without any problem.

    But, typing (https://95.179.165.242), which is unfortunately set as the homepage URL, don't redirect to domain name and give not secure connection.

    Can you figure out what is going wrong, please?
  • Oh, then, the problem is not on the server side, maybe the theme you install, try to change the theme to test.
  • Hello,

    Changing the theme didn't solve the issue.
  • hi,

    I suggest installing this WordPress plugin and mass replace old URL's (in your case: IP address):

    https://wordpress.org/plugins/search-and-replace/
  • That solved the problem.

    Thank you so much for your many answers and long support.

    Can I delete the plugin? or should I keep it installed?
  • That's great, you can delete it or keep it if you want to
Sign In or Register to comment.

Registration Required

A VULTR.com account is required to use the forum. Click here to sign in.

Quick Links