The MU forums have moved to WordPress.org

404 page not coming (45 posts)

  1. Viennese
    Member
    Posted 10 years ago #

    Is there a way to fix the problem still showing as donncha mentioned when $_SERVER['PHP_SELF'] is blank?

  2. ckennard
    Member
    Posted 10 years ago #

    I'm having this problem too. To get the admin interface to work I deleted the contents of the .htaccess file. This got all the admin settings to work so I can create a a blog, write the first entry, create new users etc.

    However when I try to go to the new blogs I get the 404 error.

  3. Viennese
    Member
    Posted 10 years ago #

    ckennard - It sounds like you have a different problem. This thread is about 404 is not showing when it should.

  4. ckennard
    Member
    Posted 10 years ago #

    Okay, I'll start a new thread.

  5. Viennese
    Member
    Posted 10 years ago #

    I looked at what donncha said earlier here. Actually my $PHP_SELF is not empty but I am still seeing this behavior on the latest version that the 404 page and header is not showing up on a nonexisting post on the sub-blogs of an installation that uses subdirectories.

    He said it's fixed but I don't see that it's fixed. Anybody... help?

  6. Viennese
    Member
    Posted 10 years ago #

    Okay, I looked into the WPMU code and this is what I see causing the 404 not happening on all blogs except the main blog on WPMU installed using subdirectories instead of subdomains.

    In wp-settings.php,

    // Fix empty PHP_SELF
    $PHP_SELF = $_SERVER['PHP_SELF'];
    if ( empty($PHP_SELF) ||
        ( constant( 'VHOST' ) == 'no' &&
          $current_blog->path != '/' ) )
      $_SERVER['PHP_SELF'] = $PHP_SELF =
        preg_replace("/(\?.*)?$/",'',$_SERVER["REQUEST_URI"]);

    the second OR condition always evaluates to true for all blogs except the main blog on WPMU installed with subdirectories. So PHP_SELF is always replaced with the REQUEST_URI.

    What happens is:

    Main blog non-existing post

    REQUEST_URI is "blog/non-existing-post"
    PHP_SELF is and remains "/index.php"

    Sub-blog non-existing post

    REQUEST_URI is "subblog/non-existing-post"
    PHP_SELF gets changed from "/index.php" to "subblog/non-existing-post"

    Then, as flywitness posted earlier in this post, PHP_SELF and REQUEST_URI being the same prevents the 404 from happening properly.

    In wp-includes/classes.php,

    in class WP, $req_uri and $self end up the same so this:

    if (empty($request) || $req_uri == $self || strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false)

    runs this:

    $this->did_permalink = false;

    which means that in function handle_404, this:

    if ( (0 == count($wp_query->posts)) && !is_404() && !is_search() && ( $this->did_permalink || (!empty($_SERVER['QUERY_STRING']) && (false === strpos($_SERVER['REQUEST_URI'], '?'))) ) )

    returns false which prevents this:

    $wp_query->set_404();

    from happening.

    I'm not understanding why PHP_SELF is changed from /index.php to the REQUEST_URI on sub-blogs in subdirectory installations.

    Help, anyone? I've been talking to myself for some time.

    Merry Christmas.

  7. tomgf
    Member
    Posted 10 years ago #

    So far, the (quick-n-dirty) solution I found is to move one step back:

    wp-settings.php (line 239)

    - if ( empty($PHP_SELF) || ( constant( 'VHOST' ) == 'no' && $current_blog->path != '/' ) )
    + if ( empty($PHP_SELF) )

    This could probably brings old problems back but so far I haven't seen any.

  8. Viennese
    Member
    Posted 10 years ago #

    tomgf - That is what I did too. I'm not sure what the old problems were that led to the change in the first place. I haven't had any problems so far using this reverting hack.

  9. svenwiesner
    Member
    Posted 10 years ago #

    @tomgf your fix solved my problems which nuts me the past three days, thnx alot!

  10. tomgf
    Member
    Posted 10 years ago #

    Any idea for a more consistent fix? After the last upgrade this hack was obviously gone…

    By the way, on wpmu-2.7 the proposed hack is on a different line:

    wp-settings.php (line 270)

    - if ( empty($PHP_SELF) || ( constant( 'VHOST' ) == 'no' && $current_blog->path != '/' ) )
    + if ( empty($PHP_SELF) )
  11. xyzzy
    Member
    Posted 10 years ago #

    I am seeing this problem too. @tomgf, your fix solved the problem for me on 2.7. However, I am not sure if it will cause any additional problems?

  12. augustas
    Member
    Posted 10 years ago #

    I get the same problem with WPMU 2.7.1

    I submitted the the bug:
    http://trac.mu.wordpress.org/ticket/995

  13. tomgf
    Member
    Posted 10 years ago #

    On the ticket page donncha says that this quick'n dirty solution breaks things for sub-domain installs.

    I proposed there a different one (will it cut it for v. 2.8?):
    wp-settings.php (line 281)

    - if ( empty($PHP_SELF) || ( constant( 'VHOST' ) == 'no' && $current_blog->path != '/' ) )
    + if ( empty($PHP_SELF) || ( empty($PHP_SELF) && constant( 'VHOST' ) == 'no' && $current_blog->path != '/' ) )
    	$_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace("/(\?.*)?$/",'',$_SERVER["REQUEST_URI"]);
  14. stillatmylinux
    Member
    Posted 10 years ago #

    Having the same problem using WordPress MU 2.8.1

    Added

    ErrorDocument 404 /index.php?error=404

    to the .htaccess file to fix my problem.

  15. tomgf
    Member
    Posted 10 years ago #

    The solution I have proposed it should be done on line 315 for WordPress µ 2.8.2:

    wp-settings (line 315)

    - if ( empty($PHP_SELF) || ( constant( 'VHOST' ) == 'no' && $current_blog->path != '/' ) )
    + if ( empty($PHP_SELF) || ( empty($PHP_SELF) && constant( 'VHOST' ) == 'no' && $current_blog->path != '/' ) )

About this Topic

  • Started 11 years ago by flywitness
  • Latest reply from tomgf