Running WordPress and Drupal on Same Server – This works!
-
I spent the better part of a day figuring this out and couldn’t track down the exact answer anywhere, so I thought I would pay it forward and share the fix.
I have Drupal installed in the root and WordPress installed in a directory in the root /wp4.
Based on some discussions about the problem, I made the following changes to the .htaccess files:
To the root .htaccess file, I added the following to the rewrite rules:
RewriteCond %{REQUEST_URI} !^wp4
so now that block looks like:
# Rewrite URLs of the form 'x' to the form 'index.php?q=x'. RewriteCond %{REQUEST_URI} !^wp4 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !=/favicon.ico RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
This tells Drupal to rewrite any URI if it is not(!) beginning with(^) wp4.
In the wp4 directory, based on some code that I found, I originally put:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase /wp4/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /wp/index.php [L,QSA] </IfModule>
This only worked half way. If I tried to load domain.com/wp4, it worked fine or domain.com/wp4/?search-listings=true it worked as well. However if I tried to load domain.com/wp4/search-for-homes/ Drupal would field the call and would give me a Drupal 404 page.
I also have Zenphoto running on a directory on the site and it has always worked fine for me, so I tried putting its htaccess instructions in the wp4 htaccess file. This is the new wp4 htaccess:
<IfModule mod_autoindex.c> IndexIgnore * </IfModule> <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /wp4 RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [L] RewriteRule ^.*/?$ index.php [L,QSA] </IfModule>
Notice it is similar, but slightly different from the original wp4 htaccess file and it works for all instances.
Hope this saves some others the time and trouble I had to go through to figure this out.
- The topic ‘Running WordPress and Drupal on Same Server – This works!’ is closed to new replies.