0

I've moved my Wordpress installation from my development domain to the live domain, but it keeps redirecting every page back to the old (dev) domain.

So far I've:

  1. Added

    define('WP_HOME', 'http://example.com']);

    define('WP_SITEURL', 'http://example.com');

    to 'wp-config.php'

  2. Edited the 'siteurl' and 'home' entries in 'wp-options' in the database.

  3. Re-downloaded the database and replaced every mention of the old URL with the new URL, then deleted the (live) database and imported the new one.

  4. Checked '.htaccess' for any redirects/rewrites.

  5. Cleared browser cache and server cache (multiple times - after each previous step).

It still redirects every page to the dev-url. For example, if I type in

'new-url.com/post-123'

it redirects me to

'dev-url.com/post-123'

The only thing that works is visiting 'new-url.com/wp-login.php', that way I have access to the backend. The site-/homeurls in the backend are set to 'new-url.com'.

What have I missed? Thanks in advance!

Edit: I had Q-Translate X set up to have a different domain for each language, that's what kept redirecting me to the old site. I don't know if Q-Translate saves settings in the DB, if not that would be why nothing else helped. Thanks for all the help guys!

  • export your database and search/replace all occurrences of old domain to your new domain. then re-save your permalinks and try clearing your cache/cookies – Neit Apr 20 '17 at 11:58
  • Done, done, done. No results. – Aardi Apr 20 '17 at 12:40
  • Using Notepad++ to search and replace may have missed some instances. Try a plugin like WP Migrate DB and see if that helps. Also - did you check your wp-config.php which can override WP_HOME and WP_SITEURL settings? – WebElaine Apr 20 '17 at 15:27
  • Apparently, it missed one instance (or it wasn't saved in the database / wasn't saved in the database as plaintext / ... ). I figured it out by chance while trying to set it up on a third, empty domain - I am using Q-Translate X and had set up a different domain for each language.. Thanks for the help! – Aardi Apr 21 '17 at 5:56
0

It looks like some of your old site links are there in the database. Thats why it is redirecting to the users to the old site.

My suggestion would be use this

https://interconnectit.com/products/search-and-replace-for-wordpress-databases/

Its a kind of php script. Be sure to keep the database backup before using it. This script will make search and replace the strings from the database. After that just update your permalinks.

Hope this will help you.

  • I've already changed all mentions of the old URL to the new URL in the database (see 3. in the post). – Aardi Apr 20 '17 at 13:19
  • It was an entry in Q-Translate X, I had it setup to use a different domain for each language. I don't know if QTX saves the settings to the DB, if it does this would be the correct solution (since replacing everything manually in Notepad++ seems to have missed some instances of the old URL). Cheers! – Aardi Apr 21 '17 at 6:02
1

How did you search the database entries of the old domain? If you did it manually i recommend to use wp-cli if you are allowed to install it on the server. Then you can use the command wp search-replace --all-tables "old.domain" "new.domain" (documentation) to replace your domain everywhere in the database.

Edit No.1:


Another possibility: did you changed the database settings to the new database in wp-config.php?

Edit No.2:


Did you cleared (resaved) your permalinks (Settings->Permalinks)?

  • Thanks for the suggestions: 1. I edited the .sql file with Notepad++ and used the find and replace function. 2. I've changed the database settings to the new one. 3. Permalinks have been resaved. It is still redirecting. – Aardi Apr 20 '17 at 12:02
0

This is maybe weird to say but did you change the home url in your backend? Because Wordpress uses that URL. Settings-->general--> Wordpress-adres(URL) and Website-adres(url)

Also when you echo the website url on a page of your choice , what do you see?

Edit

The next Wordpress page has everything you need to know about changing your URL Wordpress changing home URL

OPTION 1

Make sure you don't have wp-config.php with defined url's and edit the URL's in the backend like said above here.

OPTION 2

Define them hard coded in the wp-config.php like this :

define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');

Option 3

Edit your functions.php right after the <?php use this :

update_option( 'siteurl', 'http://example.com' );
update_option( 'home', 'http://example.com' );

Option 4

  1. Edit your wp-config.php fille and put in :

    define('RELOCATE',true);

After the "define" statements (just before the comment line that says "That's all, stop editing!"), insert a new line, and type: define('RELOCATE',true);

  1. Open a web browser and manually point it to wp-login.php on the new server. For example, if your new site is at http://www.yourdomainname.com, then type http://www.yourdomainname.com/wp-login.php into your browser's address bar.

  2. Login as per normal.

  3. Look in your web browser's address bar to verify that you have, indeed, logged in to the correct server. If this is the case, then in the Admin back-end, navigate to Settings > General and verify that both the address settings are correct. Remember to Save Changes.

  4. Once this has been fixed, edit wp-config.php and either completely remove the line that you added (delete the whole line), comment it out (with //) or change the true value to false if you think it's likely you will be relocating again.

Note: When the RELOCATE flag is set to true, the Site URL will be automatically updated to whatever path you are using to access the login screen. This will get the admin section up and running on the new URL, but it will not correct any other part of the setup. Those you will still need to alter manually.

Source : Wordpress changing site url

  • Both fields in the backend are grayed out (can't edit them), but they show the correct URL ('new-url.com'). Nothing happens if I echo the website URL on any page because the page being loaded belongs to 'dev-url.com' and changes to the theme on 'new-url.com' don't carry over. – Aardi Apr 20 '17 at 12:09
  • I made an extra comment. Since there a lot of things to learn about i can not type them all here but you can look at that page. if you already did everything on that page then ignore this comment – CompactCode Apr 20 '17 at 12:12
  • I also noticed you edited the database to edit your home URL etc. But did you include a slash '/' at the end? – CompactCode Apr 20 '17 at 12:13
  • The reason why they are greyed out in your backend is propably because you have defined them in your wp-config.php . When you delete that you can edit them back in your general settings (also says on the wordpress page) – CompactCode Apr 20 '17 at 12:14
  • I've read the Wordpress URL page, it didn't help me unfortunately. I've included a '/' after the URLs when I changed them in the database. I removed the lines in 'wp-config.php' and was able to change the URLs in the backend, but that didn't help either. – Aardi Apr 20 '17 at 12:20
0

With this plugin you can search and replace. They have an option for changing site URLs. I hope that it helps. https://nl.wordpress.org/plugins/search-and-replace/

  • I've already changed all mentions of the old URL to the new URL in the database (see 3. in the post). – Aardi Apr 20 '17 at 13:20
  • And you are sure that way is the same as this one? I'm sure this one works. – Thijs Apr 20 '17 at 13:26
  • Yes, I literally edited the whole database with Notepad++ and replaced over 8.000 instances of the old URL with the new URL. I did what that plug-in does by hand. Thanks for the suggestion though, it might help somebody else! – Aardi Apr 20 '17 at 14:03
  • When i had this problem it was my browser cache? Did you try to clear this already. – Thijs Apr 20 '17 at 14:22
  • Yes, I've deleted all cache and cookies and have restarted the browser multiple times (as stated in 5. in my post). – Aardi Apr 20 '17 at 14:26

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.