Solved

Need SQL statement for WordPress to fix WWW problem

Posted on 2014-09-14
3
217 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

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…
WordPress is constantly evolving, and with each evolution appears to get better and better.  One of the big drawbacks prior to version 3 was that there was no way to be able to set up a custom menu from the backend. The Old Way Adding menus is…
The purpose of this video is to demonstrate how to automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

813 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

12 Experts available now in Live!

Get 1:1 Help Now