WordPress.org

Ready to get started?Download WordPress

Forums

Bug with custom .htaccess aliases and 404 (4 posts)

  1. jaidev
    Member
    Posted 8 years ago #

    I had a couple of .htaccess urlrewrite aliases to access some of my posts. It went something of the form

    RewriteRule ^foo/alias home/blog/index.php?p=222

    Now, when you access foo/alias, the content was being generated right but the HTTP response code was being set to 404.

    I've got around this by commenting out a line in the function parse_query in wp-includes/classes.php -

    if ('404' == $qv['error']) {
    //$this->is_404 = true;

    Works fine for me, I get a 200 now. I'll leave it to the enlightened to work up an elegant fix if they feel necessary. Is there a bugzilla install where I can file a bug?

  2. rh2600
    Member
    Posted 8 years ago #

    This resolved a similar issue I had, where I was using the 404 page as my index page (long story)...

    However it was also breaking absolute links to my feeds

    This hack actually makes WordPress return index.php (as opposed to 404.php) no matter what invalid url you enter. If you enter a valid url it will go there, but anything else returns index.php

    Not sure if this is a feature or a bug ;)

  3. matthewc
    Member
    Posted 8 years ago #

    Confirmed, I just spent a couple of hours trying to work out why my 'short link' secondary rewrite rule that previously let me send short links to my pages using site.tld/post/123 stopped working:

    RewriteRule ^post/([0-9]+)?/?([0-9]+)?/?$ /index.php?p=$1&page=$2 [QSA]

    After reading this, I just removed the 404.php from the template, and now the pages display, although not correctly. It doesn't correctly show the single page view, but appears like a truncated version of the front-page. I think I'll take a hike over to trac.

  4. matthewc
    Member
    Posted 8 years ago #

    Bump. I have the following custom addition to my .htaccess to allow for short links, as well as my regular permalinks...

    RewriteRule ^post/([0-9]+)?/?([0-9]+)?/?$ /wp/index.php?p=$1&page=$2 [QSA,L]

    now, if i visit:

    http://carroll.org.uk/?p=68

    the page is displayed correctly, but if I go to

    http://carroll.org.uk/post/68

    the correct post is shown, but the view is like the front page of the site (without comments). any ideas why? anyone?

Topic Closed

This topic has been closed to new replies.

About this Topic