Let me get this straight ... You have an installation of Drupal in <DocumentRoot>/drupal/
. You do not want to alter the drupal installation directory, nor you want to change DocumentRoot
in your webserver config. You want to redirect any request, for example /foobar.php
, into the drupal directory, resulting in maybe /drupal/foobar.php
. And all that without exposing the whole stuff to the user. Right so far? OK, I can only assume that you have an Apache webserver, else .htaccess would not work...
First, make sure that you actually are allowed to use .htaccess, so check on the relevant AllowOverride
directive in your apache config.
Then try it this way in your <DocumentRoot>/.htaccess
:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/drupal.*
RewriteRule ^/(.*)$ /drupal/$1 [P]
RewriteCond ensures that you do not run into an infinite loop. The first part of the RewriteRule is always the URL requested by the client. We prefix the part matched inside the parentheses with /drupal/
and force it to be a proxy request via [P]
so that apache would only do an internal redirect (instead of sending the client a "Document has moved" redirection code).
BTW: I did not test it. I may have typos in the code. Read http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewriterule for more information.