1

My development computer recently had to be rebuilt so I am now trying to migrate a WordPress site from the hosting company to my development PC. So far I have done this:

  1. Installed XAMPP.

  2. Download the PHP files using FTP and put them in htdocs\mysite

  3. Create a virtual host called: localhost.MySite.

  4. Export the .sql from the host using PHPMyAdmin

  5. Open the .sql and to a find and replace replacing: www.mysite.co.uk with: localhost.MySite

  6. Use PHPMyAdmin on my local PC to load the .sql

  7. Make changes to wp_config.php:

    define('WP_HOME', 'http://localhost/mysite');
    define('WP_SITEURL', 'http://localhost/mysite');
    

Everything appeared to work e.g. the multi sites; the admin panel etc. The only issue I have is when I logout of the admin panel; I am redirected to: http://wp-login.php/?loggedout=true instead of: http://localhost.MySite/wp-login.php/?loggedout=true. What can I do?

I have spent a while Googling this e.g. I have looked here: https://wordpress.org/support/topic/logout-redirect-not-working-3/page/2/

This issue does not happen on the live website.

Update

I only appear to have theis issue on the root site of the multi site.

1 Answer 1

0

I have traced the problem to this code in wp-login.php:

case 'logout' :
    check_admin_referer('log-out');

    $user = wp_get_current_user();

    wp_logout();

    echo "hello";
    echo $_REQUEST['redirect_to'];

    if ( ! empty( $_REQUEST['redirect_to'] ) ) {
        $redirect_to = $requested_redirect_to = $_REQUEST['redirect_to'];
    } else {
        $redirect_to = 'wp-login.php?loggedout=true';
        $requested_redirect_to = '';
    }

It appears if I change this line:

$redirect_to = 'wp-login.php?loggedout=true';

to this:

$redirect_to = 'http://wp-login.php?loggedout=true';

Then it works as expected. Not sure why. In fact I can also change it to any of the following and it still works as expected:

$redirect_to = 'http://';

or

$redirect_to = 'http://somerandomsite';

Not sure what is going on.

3
  • "to this: $redirect_to = 'http://wp-login.php?loggedout=true';" - To clarify, you are actually changing it to the undesirable URL you were being redirected to (as stated in the question)? And this "works"?!
    – MrWhite
    Commented Sep 4, 2020 at 16:00
  • @MrWhite, thanks. So what do I change it to?
    – w0051977
    Commented Sep 4, 2020 at 16:15
  • Well, I don't really think that code should be "changed". WordPress will likely overwrite your efforts in a later update? (I'm sure there must be something else that can be "fixed"?) What version of WP are you using? In "later"(?) versions, the URL is not hardcoded here and is instead populated with a call to wp_login_url(). There are several sanitization/validation checks performed after this point in the code, so setting $redirect_to to something invalid (which appears to be what you are doing here) is probably just resulting in the value defaulting to "something else"?
    – MrWhite
    Commented Sep 8, 2020 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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