Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As described in this blog I want to rewrite internally

http://xy.user.phpfarm.lan -> http://user.phpfarm.lan/~xy/

Module userdir is enabled.

With the following Apache2 vhost config file, it has got a bug:


<Virtualhost *:80>
 ServerAdmin root@localhost
 ServerName em-sv-phpfarm.lan
 ServerAlias *.user.phpfarm.lan user.phpfarm.lan phpfarm.lan

 DocumentRoot /var/www/
 <Directory />
  Options FollowSymLinks
  AllowOverride None
 <Directory /var/www>
  Options Indexes FollowSymLinks MultiViews
  AllowOverride None
  Order allow,deny
  allow from all

 ErrorLog ${APACHE_LOG_DIR}/error.log

 # Possible values include: debug, info, notice, warn, error, crit,
 # alert, emerg.
 LogLevel warn

 CustomLog ${APACHE_LOG_DIR}/access.log combined

 RewriteLog "/tmp/rewrites"
 RewriteLogLevel 5
 # Uncomment the above two lines and watch /tmp for some debug info.

 RewriteEngine On

 # Make bob.user.phpfarm.em.lan be treated as user.phpfarm.lan/~bob
 RewriteCond %{HTTP_HOST} ([^.]+)\.user\.phpfarm\.lan$ [NC]
 # In the above line make sure you escape (preceed with a backslash) every period (.) in the address.
 RewriteCond %{REQUEST_URI} !^[^/]+/~.*$
 # exclude file handler
 RewriteCond %{REQUEST_URI} !^/php-fcgi/.*$
 RewriteRule ^/([^~]+) /~%1/$1 [PT,L]

So I think an empty REQUEST_URI isn't captured correctly. But I can't find the bug. Does anybody know, why?

share|improve this question

Try replacing the last line with

 RewriteRule ^/([^~]*) /~%1/$1 [PT,L]

You were insisting on at least one character after the slash, so cases where REQUEST_URI was / were being ignored.

share|improve this answer

Oh be the way: You have to change AllowOverride None to AllowOverride All

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.