Installing WordPress in Drupal’s sub directory
Last week one of my clients asked me to move her blog which is using wordpress to a new server under Drupal sub directory. So for example the main website is www.mywebsite.com and this main site is using Drupal and I have to setup wordpress under blog directory or www.mywebsite.com/blog/. As you know that Drupal htaccess file will intercept all requests to the main site and that will cause some problems to the wordpress site. Then what should we do is:
Update Drupal Htaccess
edit Drupal htaccess file so that it will exclude blog directory, we just need to add this line of code RewriteCond %{REQUEST_URI} !^blog before processing index.php, here is the complete code:
# Pass all requests not referring directly to files in the filesystem to # index.php. Clean URLs are handled in drupal_environment_initialize(). RewriteCond %{REQUEST_URI} !^blog RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !=/favicon.ico RewriteRule ^ index.php [L]
Update WordPress Htaccess
edit you WordPress htaccess file. we will add RewriteBase line since the wordpress will run under /blog directory and also we will update the rewrite rule to index.php file. here is the complete code:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase /blog/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /blog/index.php [L] </IfModule>
That’s it now your wordpress will run under Drupal subdirectory without a problem