I am developing a portal on WordPress and have a lot of plugins, posts, categories etc. in place. Now, I wanted to try three themes parallely.
So, I created two more copies of the folder in my local apache’s webroot as:
/wpSandbox/ [original, working still !]
/wpSandbox2/ [copy 1]
/wpSandbox3/ [copy 2]
Similarly, I replicated the database dbWordpress for the original portal using phpMyAdmin twice and then changed correspondingly in wp-config.php
Now, the two new copies (which I expected to be bases for testing the new themes) can’t login to admin.
In fact,
127.0.0.1/wpSandbox2/wp-admin/
actually redirects to:
127.0.0.1/wpSandbox/wp-admin/
and can’t log in using same credentials that work for the original copy… 🙁
Please tell me why this could be happening, is something else required to be altered in wp-config for the copies..?
Regards
Chances are you need to update your database with the new URL. That’s why it is redirecting.
Copy the code below and run it in phpMyAdmin (make sure you change the 3 variables at the top… I set them to what I think you should set them, but it could be different the way your database is set up)
Gist: https://gist.github.com/doitlikejustin/6091841
Just a bit of info on this code/Gist… I move WordPress sites ALL the time. This is just some SQL that I have written so that updating the database takes less time and you don’t have to worry about manually updating URL’s. It automatically updates the WP options table and WP posts table.
The redirection problem is because of
siteurl
in your original wordpress settings. Add these lines in youwp-config.php
. You may have to change the url to suite your needs.update as_options set option_value=”{new_wp_url}” where option_name=’siteurl’;
update as_options set option_value=”{new_wp_url}” where option_name=’home’;
UPDATE as_posts SET guid = REPLACE(guid, ‘{old_url}’, ‘{new_url}’)
UPDATE as_posts SET post_content = REPLACE(post_content, ‘{old_url}’, ‘{new_url}’)
Below is the SQL query that you can run to change the values to new url for wordpress sites.
After that you can run the SQL query and access the new wordpress site at your new wordpress url. And everything should work fine.
I have been using above SQL frequently and has worked for me so far. If you have any problem, then let us know. Basically the above SQL queries are equivalent to @doitlikejustin code provided above.