WordPress is Redirecting to Old URLs
WordPress is redirecting to old urls, if you have faced this problem and visiting this page, you are at the right place. I faced this issue when I moved a website and setup all the required things but it was redirecting to old URLs. I moved a client’s website from old server to a new server and there was a requirement to test the application with another URL to make sure that everything will work perfectly well. After moving to new server and replacing the URLs in options table under the wordpress DB i tried to access the website but it was redirecting to old server. I wasted my 2 hours to figure out why this was happening. I tried Database Search and Replace Script in PHP which replaced all the URLs of my website in the DB and everything must have worked perfectly OK but it was not working at all.
This script is very good and it worked most of times but this time there was something else which was creating the problems.
you can follow the under given link to get this script:
https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
I started to check each and every corner of the configuration of the WordPress and then found that it was configured on windows server and there was a web.config file which was having URL scan entries to rewrite the canonical name of the website from parent domain towards www DNS record. I replaced the URL with the updated one and it worked perfectly good. WordPress on windows server is exciting but you have to change your way of thinking to configure it and also run it securely. There are multiple issues which can create lot of problem while work with WordPress on Windows like permission and file upload handling. this can be achieved but for that you gave to be good in configuration of windows permission and also know the exact locations of the directories.
Feel free to share your valuable comments on this post.
I prefer using WordPress plugin for this. Previously I was using Search and Replace but it became obsolete. Now I prefer using Better Search Replace.
https://wordpress.org/plugins/better-search-replace/