Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

As described in http://cjmaclachlan.blogspot.de/2008/02/modrewrite-moduserdir-subdomains-and.html I want to rewrite internally

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

userdir is enabled.

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

/etc/apache2/sites-enabled/phpfarm:

<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>
 <Directory /var/www>
  Options Indexes FollowSymLinks MultiViews
  AllowOverride None
  Order allow,deny
  allow from all
 </Directory>

 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]
</virtualhost>

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.