My wordpress site gets redirected automatically to the old site any known solution for this?

wordpress.stackexchange https://wordpress.stackexchange.com/questions/358876

  •  18-04-2021
  •  | 
  •  

Question

I had recently moved my wp site from a domain to other, but when I type in the new domain's address it gets redirected to the old domain/some_page.

Is this any common problem? Is there any known solution to this?

I had checked my code and it has no redirects to this page. Can someone give me a hand on this?

Was it helpful?

Solution

This is because the URL settings inside WordPress are still pointing to the old WordPress site. More information is available in the Moving WordPress documentation.

If your WordPress admin pages are still working, you can go to Settings → General, and change the WordPress URL and the Site Address to the correct values.

If your WordPress site is completely broken, then you can add the following values to wp-config.php, which will have the same effect:

define('WP_HOME', 'http://your_server/blog');
define('WP_SITEURL', 'http://your_server/blog');

Note that in most cases, WP_HOME and WP_SITEURL will be the same, apart from exceptional circumstances.

OTHER TIPS

Give DNS 12-24 hours to propogate and flush the DNS cache on your PC.

Check wp-config.php for hardcoded URLs and change them, if needed.

Search your database with phpmyadmin for all occurrences of the old URL using interconnectit.com WordPress Serialized PHP Search Replace Tool.

Reset Dashboard>>Settings>>Permalinks and be sure .htaccess is writable.

Check your theme files for hardcoded URLs.

If using HTTPS change the value for wordpress-https_ssl_host in the wp_options table.

The above answer didn't work for me. See https://wordpress.stackexchange.com/a/179788/107311 by James

change "siteurl" and "home" in the database table "wp_options" (through phpMyAdmin or similar)

If adding the bellow is not working but only for the default directory in word press, congrats there should be no problem. You have a cache problem (if you don't care for the reason just skip to the bottom), which you cant use the normal refresh to fix. The reason is as soon as you go the the url you get redirected to a new url and then when you refresh you actualy refresh the new url not the old cache, so the fastest fix it is just to clear the cache & history.

define( 'WP_HOME',    'http://your_server/your_blog_url' );
define( 'WP_SITEURL', 'http://your_server/your_wordpress_url' );

special note: if you look in the wp_options table the first 2 entries also reference to the perm link fast command to find it bellow

select * from wp_options limit 2

Just try clearing your browser cache & history, alternatively just open it in a browser you don't use much. If it works its a cache problem.

Export the database (in .sql) and search for the domain it is redirecting to. If you don't see it maybe it's a (mu-)plugin that has old url hard coded. In some instances it the browser could cache the redirect so try accessing the site with private/incognito window/tab.

Here’s a checklist

  1. Search and Replace domain in database
  2. Update wp-config.php with new domain
  3. Check DNS propagation
  4. Clear your cache and disable caching plugins
  5. Check web server to see if there are any server level redirects.
  6. Disable All Plugins while testing and apply default theme.

If it still doesn’t work then please provide details of your web server hosting setup and platform.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top