InMotion Hosting Support Center

Help pointing non-www site to www - getting "error establishing a database connection"

Category: Wordpress

bharari
Asked:
2013-01-25 2:57 pm EST

Hits: 832
Hi,

I'm trying to redirect my Wordpress site to point from non-www to www. That is, http://bharari.net should point to http://www.bharari.net.

I tried to do this 2 different ways. Using the 301 redirection method, I modified .htaccess to point non-www to www. When I do this I get a redirect loop error.

So I tried another way. In cPanel, I made the following updates in wp-config.php (added "www" after http://):

define('WP_HOME','http://www.bharari.net');
define('WP_SITEURL','http://www.bharari.net');

I also went to MyPhpAdmin and updated the siteurl value of wp_options table for the database to include "www".

After I do all this, I get an "Error establishing a database connection" when I visit my web site.

what am I doing wrong? I've undone the changes for now.

Many thanks!

You must login before you can ask a follow up question.

You must login before you can submit an answer.

Best answer chosen by User

0

JacobIMH
9,968 Points
2013-01-25 3:52 pm EST
Hello bharari, and thank you for your question.

I went ahead and corrected this for you. In order to get WordPress to properly always append the <strong>www.</strong> before your domain name both of these settings have to be set in the database in your <strong>wp_options</strong> table:

siteurl = http://www.bharari.net
home = http://www.bharari.net

I think the problems you were having were that you were trying to force the <strong>www</strong> with your <strong>.htaccess</strong> file prior to setting up WordPress to use this, so when it attempted to connect over <strong>www</strong> WordPress internally would redirect it back to without that appended, which would lead to a redirect loop.

I've left the options commented out in your <strong>wp-config.php</strong> file since they're getting included directly from the database now. I've also left in the <strong>.htaccess</strong> code to force using the <strong>www</strong> which isn't required to have it work with WordPress, but if you had any other pages outside of WordPress on your site this would allow them to all be over <strong>www</strong> now as well.

Please let us know if you have any further questions at all.

- Jacob

You must login before you can post a comment about this answer.

Like this Question?

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!