Apache document root RewriteRule error

While customizing this homepage I came across the following problem: I wanted to rewrite every request which accesses the root of this page to access the subfolder "drupal". This way t is possible to use "www.phillme.de" to see the blog and additionally allow subfolders on the same level as the "drupal" directory.

My first guess was to use the following in a .htaccess-file in the document root:

RewriteEngine on
RewriteRule	^/$	/drupal/

Sadly enough it did not work although the url rewriting guide of apache at http://httpd.apache.org/docs/2.2/rewrite/rewrite_guide.html exactly mentions the same solution for a moved document root.

The solution described there is the following, which is very similar to my initial yet not working attempt:

RewriteEngine on
RewriteRule   ^/$  /about/  [R]

Of course I also tried the "[R]" for redirect with the same problem. The redirect was not triggered. Fortunately I found another site with "very common mistakes" about rewrite rules (http://rewriterule.alantait.com/4/). It mentions that the RewriteRule does NOT have the beginning "/" which transforms my initial solution to

RewriteEngine on
RewriteRule	^$	/drupal/

without the root slash and... finally it works.

I am wondering if this is an error in the apache documentation or if I just got something wrong. Maybe someone can brighten the for me. All others may consider the solution above ;-).

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Email addresses and mailto: links will be obfuscated to hide them from spambots but still be readable to javascript-enabled browsers.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <drupal5>, <drupal6>, <javascript>, <php>, <python>, <ruby>. Beside the tag style "<foo>" it is also possible to use "[foo]".
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.