Thursday, February 14, 2008

WordPress Mod Rewrite Make Subdirectory 404 Error

Last night, I getting lots of 404 error while using Google to search my own blog index page, I realized there is something wrong about my blog.

My user-created-outside-of-WP folder is throwing a 404 when trying to access it. Now for some details:

Blog www.moon-blog.com : normal WP blog. Permalinks "/%year%/%monthnum%/%postname%.html" through mod_rewrite in the default .htaccess file WP created.

Subdirectory www.moon-blog.com/MySubdirectory/): normal PHP application. User defind permalinks. Located at directory "/MySubdirectory/".

The problem is that the WordPress thinks My Subdirectory is 404, and do not allow Google to index my files.

I Try add some of php code into my php application to resolve this problem:

header("Status: 200 OK");

After adding that code, my PHP application in the subdirectory do not return 404 error again.

6 comments:

  1. Thank you very much. I was struggling with this for a few hours.

    I have a Wordpress plugin that adds some mod rewrites to redirect certain urls (like "/products/product1") to a file in the plugin folder. IE6&7 were giving me random 404 errors... usually when I tried to refresh while the page was still loading.

    Anyway, adding the header 200 OK code to the top of the PHP scripts fixed it.

    This is a really weird fix. Shouldn't PHP be sending 200 status by default anyway?

    ReplyDelete
  2. Wow. That did work. Thanks so much for sharing this! The 404s were driving me nuts.

    ReplyDelete
  3. I am trying to install a new theme in word press 2.0 but any theme i chose it comes up with an error "Broken Theme" and "style.css is unreadable".
    Any comments much appreciated.

    ReplyDelete
  4. Wow. That did work. Thanks so much for sharing this! The 404s were driving me nuts.

    ReplyDelete
  5. [...] English edition: WordPress Mod Rewrite Make Subdirectory 404 Error [...]

    ReplyDelete
  6. which php document did you insert the line of code into?

    ReplyDelete