Solved

Need SQL statement for WordPress to fix WWW problem

Posted on 2014-09-14
3
220 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
ID: 40321836
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
ID: 40321888
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
ID: 40321914
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Do you think that WordPress is just for blogs?  Think again!  WordPress is really a fantastic all around platform that you can use to develop websites on.  Integrated into its basic functionality is the ability to create pages using your choice of a…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…

830 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