Please help me to overcome the redirection issue.

I need to work on subdomain rather than working on the main domain but here both domain is different.

What I did is - copied all (website.com) files to another subdomain(demo.websiteA.com) and changed the database name as per wp-config.php file.

But whenever I try to open demo.websiteA.com it redirects to website.com

Please help me out

Thanks in advance

  • Did you also change your sites url to match the new domain/subdomain? – funkysoul Jul 9 '18 at 8:14

If you can log in to phpmyadmin, you can check the wp-options table in the database to check the value below, if it's website.com, you must edit two line below is demo.websiteA.com

enter image description here

|improve this answer|||||

In addition to the above, you need to change all references of old site URLs to new site URLs. Try this plugin's 'Find & Replace' option - https://wordpress.org/plugins/wp-migrate-db/ and don't forgot to delete cache.

|improve this answer|||||

You can replace the old Wordpress URL with these SQL Queries:

# Options
UPDATE wp_options SET option_value = replace(option_value, 'website.com', 'demo.websiteA.com') WHERE option_name = 'home' OR option_name = 'siteurl';

# Posts & Postmeta
UPDATE wp_posts SET post_content = replace(post_content, 'website.com', 'demo.websiteA.com');
UPDATE wp_posts SET guid = replace(guid, 'website.com','demo.websiteA.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'website.com','demo.websiteA.com');

# Usermeta
UPDATE wp_usermeta SET meta_value = replace(meta_value, 'website.com','demo.websiteA.com');

# Links
UPDATE wp_links SET link_url = replace(link_url, 'website.com','demo.websiteA.com');

# Comments
UPDATE wp_comments SET comment_content = replace(comment_content , 'website.com','demo.websiteA.com');
UPDATE wp_comments SET comment_author_url = replace(comment_author_url, 'website.com','demo.websiteA.com');

Replace: "website.com" with your Old URL

Replace: "demo.websiteA.com" with your New URL

|improve this answer|||||
  • What happens if you change a serialized object? – Drupalizeme Jul 9 '18 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.