In Drupal 6 I was able to successful install Drupal in a subdirectory called drupal and then reference the site without having to use example.com/drupal. In Drupal 6 to get this to work I did the following: - Created an .htaccess file in the root directory where /drupal was created. The file contents was:
Options -Indexes
RewriteEngine On
RewriteRule ^$ drupal/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ drupal/$1
Updated the drupal/sites/default/settings.php
file to have the $base_url defined as:
$base_url = 'http://example.com';
When I try and do the same thing for Drupal 7, only the front page can be displayed, all the pages fail quite horribly (or only display the front page). I have also tried uncommenting the RewriteBase lines in /drupal/.htaccess. First I tried RewriteBase /drupal
and then tried RewriteBase /
. But both attempts failed. I never needed to do this with D6, but I thought I would rule out this possible fix.
I am currently testing the new Drupal 7 install using xampp (version 1.7.4) with the example.com site under htdocs (i.e. xampp/htdocs/example.com/drupal). The Drupal 6 site is within the same xampp installation, but of course with a different directory path (e.g. xampp/htdocs/d6example.com/drupal). Note that I also have the Drupal 6 installation running on a production server with only the $base_url variable value changed.
So, how can you install Drupal 7 in a subdirectory and then run it from that directory without having the directory name in the URL? Note I am installing Drupal 7 in a subdirectory as it allows for easier upgrading between new releases of the Drupal 7 core.
On Apache server, add this to the root .htaccess file.
RewriteEngine on RewriteRule (.*) drupal/$1 [L]
Update the drupal settings.php file (in /drupal/site/default/ directory) so that the $base_url line reads:
Try with this :
Put this .htaccess file in example.com directory. You don't have to modify drupal7 .htaccess
I answered a very similar question on this here: Two Drupal installation on the same server My answer to your question is the same, I recommend eschewing the rewrite method in favor of the virtual host method as described below (which is just an excerpt of what I answered in the link above):
In your case, however, you would only require one virtual host entry & not two.
Additionally, it should be noted that, should you desire to serve a site from a location NOT in your webroot then you would also need a
entry to tell Apache what access to give to visitors (NOTE: in Linux the Apache user should be made owner of the files [or permissions should be set in a method that still allows the apache user rights to serve the files if you want to avoid giving it ownership])