How to Redirect a non-WWW to WWW URL in WordPress?

Redirect a non-WWW to WWW

How to Redirect a non-WWW to WWW URL in WordPress?

Oct 5, 2016 – 2 min read

Description

Let’s say that we have installed WordPress and we want to redirect a non-WWW URL to WWW URL.

example.com

to

www.example.com

Here are the steps we may follow initially if we want to redirect a non-WWW to WWW URL:

  • Log in to the WordPress administration of your website.
  • From the main menu open “Settings” -> “General”.
  • Change the fields “WordPress Address (URL)” and “Site Address (URL)” from example.com to www.example.com (with https:// or http:// depending on if you use SSL or not).
  • Scroll down and press “Save Changes”.

There are cases when after this change, you will be no longer able to access your website (including the administration) through example.com or www.example.com.

Possible issue with the DNS records

Every time when we hit example.com, the request initiated by your web browser will be sent to the nearest DNS server whose job is to forward the request to the IP address of the server where you host your website. But there might be cases when the DNS server misses the information about what to do when somebody requests the domain name with WWW, example: www.example.com. Therefore it cannot redirect non-WWW to WWW URL. From DNS point of view, this is a different domain name and if there is no record for it, it couldn’t know where to forward the request.

Set up a DNS record

Open the administration of your domain name (Name.com, GoDaddy, Domain.com or else) and add the following CNAME record:


Hostname: *
Target Host: example.com

This CNAME record is called a Wildcard record because what it does is to tell the DNS servers to forward all requests regarding www.example.com to the IP address associated with the domain name example.com.

Additional

Here are a few things to consider checking:

If you need assistance with WordPress or your website, contact me.

(The header image is taken from DigitalOcean website.)

0 0 vote
Article Rating
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x