Multiple WordPress blogs, single server, 404 pages, and .htaccess

Discussion in 'Integration' started by karnesb, Aug 14, 2008.

  1. karnesb

    karnesb New Member

    Joined:
    May 25, 2008
    Messages:
    26
    This message is directed specifically to skippybosco; however, since the topic may be of value to another down the road, I wanted to express my appreciation publicly on this board.
    ----------------------

    skippybosco,

    For weeks, I had been trying to figure out how to get one of my WordPress 404.php template pages to be recognized on one of the two WP blogs I have running on a single server. The config for the two blogs is:

    Blog 1 location (server root)
    www.domain.com/

    Blog 2 location (sub-directory) (Amember protected)
    www.domain.com/memberzone

    Relying on WorPress's innate systemization, and without making any changes to the .htaccess files, I visited bogus pages on my sites to test the custom 404 pages. The 404 page for the root WP blog consistently came up. The sub-directory's blog did not go to ITS 404 page, but the 404 page for the root blog's site. That would be all fine and good, except Blog 1 is public, Blog 2 is Amember protected, and each blog has a different look and feel. Besides, shooting an unsuspecting user to the non-Amember blog would confuse them - thinking they'd been kicked out of the member section or something.

    So, as any good webmaster would, I added the customary code to the sub-directory's .htaccess file, like so:

    ErrorDocument 404 /memberzone/index.php?error=404

    Keep in mind, with /memberzone being an Amember protected directory, there is all sorts of aMember code in that .htaccess file, and I wanted to be sure I inserted the ERRORDOCUMENT code in such as way as to (1) achieve my goal, and (2) not interfere with the processes of the Amember code. In the end, I inserted the code as the final line in that file, and had the following success.

    Netscape and Foxfire's browser's were working just fine, finding my 404 page 100% of the time. But, IE6 & 7 were not. They'd hit the page 2% of the time and get thrown to the standard server 404 page 98% of the time. That sucked. So, I knew it had something to do with WordPress getting confused by the existence, and locations of the two blogs, thus impacting the server's ability to identify which direction to go. Needless to say I tried this, that and the other thing, which did a lot for helping me understand the server's search and travel patterns, but nothing to solve my problem. I FINALLY found a line of code in one of your posts, skippybosco, on Word Press' Forum that solved my problem. That post is here:

    http://wordpress.org/support/topic/173031

    The line of code I found was this...

    RewriteCond %{REQUEST_URI} ^/lectures/ [OR]

    And, I inserted it (with my directory name substituted for /lectures/) into the .htaccess file located at the root of my site, where Blog 1 lived, as shown below. PURPOSE: to tell the server to rewrite all virtual, and other files to the root EXCEPT those under the /memberzone directory.

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} ^/memberzone/ [OR]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress

    Just FYI for those reading this post, who have a WordPress blog... the lines of code above ARE the standard code that gets installed into the .htaccess file at the root location of your blog, except for line 5, which I got from skippybosco.

    Now... all of my aMember code still works - even the customized code they wrote for me to assure a user who typed in a specific url under a protected directory in WordPress, other than the main index.php page, would direct them TO that actual link after their log in. All of my WordPress pages and links still work. AND, my error pages, including my 404 page, are all directed to the correct locations.

    THANKS skippybosco so much for taking the time to share your intellectual property here, and on other forums! You never really know who, or how many you are reaching, and whether the time it takes to submit a post will be worth the investment. But then, again... sometimes, even without knowing it, you change people's lives!

    Your the best!
    Barbara
  2. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    Thank you for the kind words Barbara. Your post really made my day.

Share This Page