What to do if your WordPress host IP changed

If your WordPress host IP changed accidently and and you can not login into WordPress, there are several ways to update the site URL without logging in. Then your site will be working properly. If your site does not, check your .htacess file in which you may have settled some redirect rules with the old IP, replace all the old IP with the new IP.

Change the site URL

Changing the site URL provides several ways to change the site URL and this article gives two more ways, choose one you like and then try to refresh your site a couple of times, your site will be OK.

Change URL in database through phpmyadmin

Even your WordPress site does not load, you can access the phpmyadmin tool.

In wp_options table, update two records whose option_name is siteurl or home. Make the records are listed ascendingly by option_id, you can easy find these two records.

Change URL in database through terminal

Open a terminal, connect mysql with mysql -u root -p or /path/to/your/mysql -u root -p if your mysql is not in the path. Here it suppose your mysql user is root. It will prompt you input the password. If you forget, check them in your wp-config.php file.

Input use to select the database you want to change. You can also find the database name in your wp-config.php file. Then you can update the options whose option_name is siteurl or home like below.

# Connect mysql
$ /myfolder/mysql/bin/mysql -u root -p
Enter password: ********
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 2
Server version: 10.1.31-MariaDB mariadb.org binary distribution

# Choose database
MariaDB [(none)]> use my-database-name
Database changed
MariaDB [training]>

# You can check the old values for the option whose option_name in ('siteurl', 'home')
MariaDB [training]> select * from wp_options where option_name in ('siteurl', 'h
    -> ;
| option_id | option_name | option_value         | autoload |
|         2 | home        | http://xxx.xxx.x.xxx | yes      |
|         1 | siteurl     | http://xxx.xxx.x.xxx | yes      |
2 rows in set (0.12 sec)

# Update the values with the new IP
MariaDB [training]> update wp_options set option_value="" wh
ere option_name in ('siteurl', 'home')
    -> ;
Query OK, 2 rows affected (0.09 sec)
Rows matched: 2  Changed: 2  Warnings: 0

MariaDB [training]> exit

Edit functions.php

Edit your functions.php of your currently used theme, add these two temporary lines to the file, immediately after the initial <?php line:

update_option( 'siteurl', '' );
update_option( 'home', '' );

Use your own IP instead of

Load the admin page a couple of times, the site should come back up. Then remove them after the site is up and running again.

Edit wp-config.php

Add these two lines to your wp-config.php, where “example.com” is the correct location of your site.

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

Note it’s just hard-coding the values into the site itself. You won’t be able to edit them on the General settings page anymore when using this method.

Change old IP in your .htaccess file if any

If your site does not come back, check your .htaccess (probably the top-level .htaccess) file and replace all the old IP with the new one if any.

Setting up Your Domain Email on WordPress with Amazon SES

If you want to send emails from your own domain, Amazon SES is a preferred solution especially you are running a business site. Despite it is not free, the cost is cheap. AWS charges $0.10 every 1000 emails and $0.12 each GB of data.

Amazon SES

Excepting sending emails from your own domain (Need to verify your domain), Amason SES also allows you to send emails using your own email addresses (Need to verify your email). If you just want to send emails using your own email (such as john@gmail.com) on your WordPress site, skip the step 2 in below procedure.

For receiving emails, AWS SES does not provide an email inbox, but it can deliver incoming emails to an Amazon S3 bucket (it will be charged), publish it to an Amazon SNS topic, or operate an AWS Lambda operation, etc.

If that is not what you want to do with receiving emails, you can forward the received emails to your another email address through your domain provider. Many domain providers give free email forwarding service. The only thing you need to do is add a MX record in your DNS zone.

Below section shows an overall process and explains each step. Refer to Enabling email for your wordpress on AWS Lightsail for stey-by-step instructions. Although it’s about WordPress on AWS Lightsail, the guide applies to all WordPress sites no mater your site is on Amazon Lightsail or not. There are differences just when it comes to setting DNS records part. Skip the first two steps in the guide and start from step 3 (It is marked as step 1 in the following procedure).

Steps to set up your own domain Email on WordPress

Step 1: Create SMTP credentials in Amazon SES

Creating SMTP credentials in your Amazon SES will create a SMTP user and password. This credential will be used when you configure WordPress to send emails using Amazon SES.

Step 2: Verify your domain in Amazon SES

This step confirms that you own the domain, prevents others from using it and enables you send emails from your domain.

In the step, you need to add several DNS records to your domain’s DNS. After that, in fact you have been able to send emails from your domain.

However, your AWS account is in the Amazon SES sandbox for the moment, this will restrict you to send emails only to verified addresses or domains (In step 5, you can make a request to move it out of the sandbox so you can send emails to any address). Therefore in the next step, you can verify an email so that you can send an email to that address to make sure everything is working.

Step 3: Verify your email address in Amazon SES

You can verify it with your own existing email address, such as john@gmail.com.

After you finish this step, then send a test email from the domain to this email:

  1. Open AWS SES Console .

  2. Choose Domains.

  3. Check the checkbox for the domain you have verified in the table.

  4. Choose Send a Test Email button on the top.

  5. Enter an email address from your domain. Assuming that your domain is example.com, you can use hello@example.com as the sender address. You can enter an arbitrary user name here, it has nothing to do with the actual users on your web site.

    Then enter the mail address you’ve verified in the prior step as the recipient. Choose Send Test Email button.

Note this step enables you to send emails using the verified email address with Amazon SES. You can send a test email using it in Amazon SES just like what you do using the verified domain.

Step 4: Configure WP Mail SMTP plugin to send emails on WordPress using Amazon SES

In this step, the credentials information created in step 1 will be used. When you finish the configure, you will be able to send emails on your WordPress site.

Step 5: Move your Amazon AWS account out of the Amazon SES sandbox

See Moving Out of the Amazon SES Sandbox for how to make a request to move your Amazon SES account out of the sandbox.

In the request, choose all of the AWS regions that your request applies to (see more on Amazon SES Regions).

After your request is passed, you can send emails from your domain to any address.

Fixing expires headers not working

After adding expires headers, you may found they are not working as expected. According to your server’s settings, there are a few situations that cause this issue.

In below checking process, assuming you are using Apache server.

Checking flow of expires headers not working

  1. Check whether .htaccess is disabled in httpd.conf of your apache (generally httpd.conf is located in the /conf folder).

    Check whether the AllowOverride option is set to None. If it is, then .htaccess is disabled. You can add the configuration for adding expires headers in the main configuration file httpd.conf.

  2. Check whether mod_expires is loaded in your httpd.conf.

    There will be a line like below if mod_expires is loaded in httpd.conf. If it is commented out or missed, fix it.

    LoadModule expires_module modules/mod_expires.so
  3. Remember to restart apache. Then you should find that the expires heading are working.