Solved

Need SQL statement for WordPress to fix WWW problem

Posted on 2014-09-14
3
212 Views
Last Modified: 2014-09-14
My client started their WordPress website with a domain and hard-coded it to not have a "www." in front of the domain. Unfortunately, this caused problems on the local "windows domain" network in the office. The LAN technician said that the website had to be changed to include "www." we did, and now we need to adjust all the references to images and pages in the website that currently do not have a "www.".

Therefore, I am looking for one or more SQL statements that I can execute in MyPHPAdmin to change all references of "http://domain.com" to "http://www.mydomain.com". This would be in at least these two fields of the wp_posts table:
post_content
GUID
There might be other fields in this table and there might be other tables to modify, too. I am not sure.

I am not an expert on MySQL, so I am not sure how to formulate the SQL statements. I am also not expert enough in WordPRess to know if there are other fields and tables to search through or not.

Thank you.
0
Comment
Question by:Lev Seltzer
3 Comments
 
LVL 24

Accepted Solution

by:
mankowitz earned 333 total points
Comment Utility
The first thing I would try is to edit your routing table so that all queries to http://domain.com are forwarded to http://www.domain.com. For example, in .htaccess for the www.domain.com site, put in this.
Redirect 301 / http://domain.com/

Open in new window

If that's not possible, then you will want a query like this:
UPDATE wp_posts set post_content = replace(post_content, 'http://domain.com', 'http://www.mydomain.com')

Open in new window

0
 
LVL 38

Assisted Solution

by:Tom Beck
Tom Beck earned 167 total points
Comment Utility
I had a similar problem and used PhpMyAdmin's search feature. Search "http://www" or something similar and it will tell you how many instances where found in each table in the database. Aside from wp_posts, you will likely find instances in wp_postmeta and wp_options. Then you can use a statement like @mankowitz suggested on each table.
0
 

Author Closing Comment

by:Lev Seltzer
Comment Utility
I managed to replace the domain name in the wp_posts, wp-postmeta and wp_options files. Thank you both for your quick and accurate replies.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In Part I (http://www.experts-exchange.com/Web_Development/Blogs/WordPress/A_8410-Getting-Started-In-WordPress-Part-I.html), I introduced you to the powerful WordPress backend, the WordPress administrative Dashboard.  In Part II, I will introduce yo…
So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
The purpose of this video is to demonstrate how to make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…
The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now