Running WordPress and Drupal side-by-side

I’ve had a case where I need to run WordPress and Drupal side-by-side.

My preferred method is to run WordPress in a sub-directory of the Drupal installation.

So the server’s document root is set to: /var/www/html/oeit/. The Drupal instance is in: /var/www/html/oeit/drupal/. And the WordPress install is in /var/www/html/oeit/haiti-oer-symposium/.

Aside: We already have a rewrite rule in place because our Drupal installation was coded to require the subdirectory <server document root>/drupal. Yes, that’s not ideal. But the rewrite rule has been a heck of a lot easier than going through and changing the custom theme and testing it out. I’m not a Drupal developer, nor do I see a particular need to become one right now.

With the rewrite rule, I needed to be able to let the WordPress rewrite rules take precedence in the /var/www/html/oeit/haiti-oer-symposium/ directory. That actually gives part of a clue as to how the problem is solved.

I originally looked for stuff like “integrate wordpress and drupal” or “run wordpress in subdirectory of drupal”. Ultimately I ran across the suggestion to have Apache ignore anything going to the haiti-oer-symposium sub-directory.

I added the following code to our .htaccess file:

RewriteCond %{REQUEST_URI} !^/haiti-oer-symposium/

Here’s an explanation from rick_deckard about how this is doing it’s thing…

RewriteCond %{REQUEST_URI} !^blog

In that case it says
If the request URI does NOT (!) BEGIN (^) with “blog” and the requested URI does not map to a file or directory, then rewrite to invoke drupal.

Put another way
If the request URI is for my blog or a file or a directory, serve that straight up, without handing me off to drupal. So in the case of your blog, it passes you through to WP

[fusion_builder_container hundred_percent=”yes” overflow=”visible”][fusion_builder_row][fusion_builder_column type=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none”][And this proved to be key…]

As for the leading slash – run the HTTP Live Headers plugin in Firefox to see what the server thinks your actual REQUEST_URI is (or use phpinfo() on your /blog directory). In my case at least, it does not want the leading slash.

[Our server did require the leading and trailing slashes.]

Source: rick_deckard

So, is it better to know what you’re doing, or just get lucky with copy and paste?[/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]

2 replies
  1. Gvanto
    Gvanto says:

    Hi there,

    Just wondering if you ever managed to get this to work?

    I have a drupal site at mydomain.com but would like WordPress blog to run at mydomain.com/blog

    Did you have any success?

    gvanto

    • Brandon Muramatsu
      Brandon Muramatsu says:

      Yes we did get it working. By following the instructions in the article. Though we have since changed configurations so the rewrite rules aren’t needed anymore. Good luck.

Comments are closed.