Knowledgebase

Redirect One-Click WordPress From IP to Domain Name Print

  • 0

Introduction

If your Rcs One-Click WordPress website responds by both domain name and IP address, you'll experience SSL issues, lower Google SEO, and confuse users. This guide helps you to solve this problem by redirecting the IP address access to the domain name.

Prerequisites

This tutorial assumes that you have deployed and installed a Rcs One-Click WordPress server, have a domain name pointing to your server IP address, and you logged in as root. Replace the examples in this guide (www.example.com and 192.168.0.123) with your domain name and IP address.

1. Change Nginx Configuration

Using SSL for websites is highly recommended. If you cannot use SSL for your website for some particular reason, then follow the steps in Option 1. Otherwise, follow Option 2.

Option 1: A Website without SSL

  1. Edit /etc/nginx/conf.d/wordpress_http.conf

     # nano /etc/nginx/conf.d/wordpress_http.conf
  2. Add the following server block at the top of the file:

     server {
             listen 80;
             server_name 192.168.0.123;
    
             return 301 http://www.example.com;
     }
  3. Save and exit the file.

Option 2. A Website with SSL

  1. Edit /etc/nginx/conf.d/wordpress_http.conf:

     # nano /etc/nginx/conf.d/wordpress_http.conf
  2. Add the following server block at the top of the file:

     server {
             listen 80;
             server_name 192.168.0.123;
    
             return 301 https://www.example.com;
     }
  3. Save and exit the file.

  4. Edit /etc/nginx/conf.d/wordpress_https.conf:

     # nano /etc/nginx/conf.d/wordpress_https.conf
  5. Add the following server block at the top of the file:

     server {
             listen 443 ssl;
             server_name 192.168.0.123;
    
             ssl_certificate /etc/nginx/ssl/server.crt;
             ssl_certificate_key /etc/nginx/ssl/server.key;
    
             return 301 https://www.example.com;
     }
  6. Save and exit the file.

2. Apply the Changes

Check the new Nginx configuration file.

# nginx -t

Apply the new configuration.

    # systemctl reload nginx.service

Test the Website

Open your browser and navigate to the server IP address. The browser will redirect to your domain name.

Introduction If your Rcs One-Click WordPress website responds by both domain name and IP address, you'll experience SSL issues, lower Google SEO, and confuse users. This guide helps you to solve this problem by redirecting the IP address access to the domain name. Prerequisites This tutorial assumes that you have deployed and installed a Rcs One-Click WordPress server, have a domain name pointing to your server IP address, and you logged in as root. Replace the examples in this guide (www.example.com and 192.168.0.123) with your domain name and IP address. 1. Change Nginx Configuration Using SSL for websites is highly recommended. If you cannot use SSL for your website for some particular reason, then follow the steps in Option 1. Otherwise, follow Option 2. Option 1: A Website without SSL Edit /etc/nginx/conf.d/wordpress_http.conf # nano /etc/nginx/conf.d/wordpress_http.conf Add the following server block at the top of the file: server { listen 80; server_name 192.168.0.123; return 301 http://www.example.com; } Save and exit the file. Option 2. A Website with SSL Edit /etc/nginx/conf.d/wordpress_http.conf: # nano /etc/nginx/conf.d/wordpress_http.conf Add the following server block at the top of the file: server { listen 80; server_name 192.168.0.123; return 301 https://www.example.com; } Save and exit the file. Edit /etc/nginx/conf.d/wordpress_https.conf: # nano /etc/nginx/conf.d/wordpress_https.conf Add the following server block at the top of the file: server { listen 443 ssl; server_name 192.168.0.123; ssl_certificate /etc/nginx/ssl/server.crt; ssl_certificate_key /etc/nginx/ssl/server.key; return 301 https://www.example.com; } Save and exit the file. 2. Apply the Changes Check the new Nginx configuration file. # nginx -t Apply the new configuration. # systemctl reload nginx.service Test the Website Open your browser and navigate to the server IP address. The browser will redirect to your domain name.

Was this answer helpful?
Back

Powered by WHMCompleteSolution