I am new to wordpress but have experience in Drupal. I am developing wordpress site which I access as localhost/site1
. I created another copy of it to experiment a few things. I can access another site as localhost/site2
. The strange thing I see now is whenever I click on a post from localhost/site2
it takes me to localhost/site1
. For example I am taken to localhost/site1/my-post
from site2 when expected is localhost/site2/my-post
. Then I checked the database and saw the links were stored in posts table in guid column. I was expecting only relative URLs to be saved in tables(as in drupal) but here the full URL is saved in database. How can I make all URLs as localhost/site2/my-post
? Also how can I make this work when I move it online to a particular domain ?
2 Answers
This is a typical issue when moving WordPress sites. WordPress stores URLs - both main configuration URLs and resource URLs - in the database. These must be changed in the database when moving to a new domain or mail URL in localhost.
Don't use simple SQL change queries in the database via adminer or phpmyadmin. WordPress and some themes store configurations and URLs in serialized data, which a simple SQL query won't correctly handle.
See Moving WordPress « WordPress Codex for full details on moving Wordpress and WordPress Serialized PHP Search Replace Tool to correctly find/replace URLs in the database.
The quickest and most hassle-free way is to download the database via phpMyAdmin, do a search and replace on the domain name and then re-upload the database. Good luck!