0

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:

/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?

masegaloeh
  • 17,978
  • 9
  • 56
  • 104
Joe Nazz
  • 171
  • 1
  • 1
  • 9

2 Answers2

1

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.

Flup
  • 7,688
  • 1
  • 31
  • 43
-2

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

PersianGulf
  • 596
  • 6
  • 21