Support » Fixing WordPress » Bug with custom .htaccess aliases and 404

  • 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?

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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 😉

    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.

    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:

    the page is displayed correctly, but if I go to

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Bug with custom .htaccess aliases and 404’ is closed to new replies.