Support » Plugins » External Site Integration gives HTTP 404 error – Possible Fix

  • Short version: I have found a bug that affects anyone trying to integrate WP with their site using the WP theme engine. It causes complete removal of non-WP site from search engine indexes. How can I submit a patch to the developers?

    Background: I am hosting my own website with a WordPress 2.9.1 install. I wanted to keep WP in a subdirectory of the site, so that the rest of the site is *not* managed by WP, but still have the rest of the site have the same appearance. I accomplished this by having my external pages load ‘blog/wp-blog-header.php‘ and major edits to the theme (I forget the exact details; anyway, it took a lot of effort and it works).

    Problem: When accessing pages outside WP, they look perfectly normal to a user, but WP spits out HTTP 404 (Not Found) headers instead of HTTP 200 (OK) headers. This caused my pages to be dropped from all search engines!

    Here are similar reports from a quick search: [WP 2.3] [WP 2.8.4]

    The solutions proposed above are to create a new plugin and load it, or manually edit the WP source code. I feel it should be corrected in the WP source code itself. Secondly, they essentially propose whitelisting all your site pages. That seems not to be scalable nor generic.

    My solution: WP only does URL rewrites within a certain directory. If any requests are for outside that directory, then WP simply should not consider it to be an error. i.e. WP has no jurisdiction outside that directory. This assumes your non-blog pages are outside, and your blog is in a subdirectory.

    This is my diff [WP 2.9.1]:

    In /wp-includes/classes.php, function parse_request():
    < 			if (empty($request) || $req_uri == $self || strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false) {
    > 			if (empty($request) || $req_uri == $self || strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false
    > 				|| strpos($_SERVER['PHP_SELF'], '/immerge/blog/') !== 0 ## zAlbee change
    > 				## it is not a rewrite unless PHP_SELF is index.php inside the wordpress install directory
    > 			) {

    Here, ‘/immerge/blog/‘ is the root of my blog. Basically, the existing code checks for cases where it’s NOT an error. I am adding the case where the request (PHP_SELF) does not match my blog root. In fact, I only need to see that it’s not ‘/immerge/blog/index.php‘, since that seems to be the page that triggers all rewrites, but I wanted to be safe. I’m sure WP has a variable for the blog root, so this code can then be generic for everyone. (Didn’t bother looking for it.)

    Could someone review this code, or point me to where I can submit a report/patch? Thanks!

Viewing 1 replies (of 1 total)
  • I ran into the same problem, and found another solution than yours:

    Instead of using this at the beginning of your scripts :

    This way, the function wp() won’t be called, and your page won’t have the 404 status attributed to it.

Viewing 1 replies (of 1 total)
  • The topic ‘External Site Integration gives HTTP 404 error – Possible Fix’ is closed to new replies.