3

Filepath: /Users/user_name/Sites/example.com

Browseable at: http://localhost/~user_name/example.com/

In a child directory (chrome) I got a .htaccess like this:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^rgba\((\d{1,3}%?,\s?\d{1,3}%?,\s?\d{1,3}%?,\s?[0-1]?\.?\d+)\)$ rgba.php?rgba=$1 [PT]

This matches a request like:

http://localhost/~user_name/example.com/chrome/rgba(255,255,255,0.5)

and should rewrite the request to:

http://localhost/~user_name/example.com/chrome/rgba.php?rgba=(255,255,255,0.5)

I put the rgba.php in the chrome directory. Still I get this error msg:

The requested URL /Users/user_name/Sites/example.com/chrome/rgba.php was not found on this server.

I read the part in the manual about Home directory expansion and the [PT] flag but it makes no difference.

If i put up a vhost pointing to the example.com directory it works. I would like it to work both ways =P

So how do I do it?

I run Apache/2.2.15 (Unix) on a Mac OS X

EDIT AllowOverride is set to All for the users Sites directory. If it wasn´t the rewrite shouldn´t have worked at all.

anddoutoi
  • 9,973
  • 4
  • 29
  • 28

3 Answers3

1

Holy god that was frustrating. But I have it working.

I tried a bunch of stuff. I thought that the PT flag on the RewriteRule would fix it, but nope.

I still don't know how to stop the home directory expansion, but I figured out a workaround. Just before the RewriteRule, use RewriteBase /~user_name/example.com/chrome/. This overrides the rewrite's prefix (log entry from my config):

<SNIP> (2) [perdir /Users/colin/Sites/ajaxtest/] trying to replace prefix /Users/colin/Sites/ajaxtest/ with /~colin/ajaxtest/

UPDATE

This solution works somewhat, but it appears to make the rewrite engine trigger twice... once for the internal redirect, and again afterwards. I ended up just using a VirtualHost like the other submitter.

Colin Dunklau
  • 3,001
  • 1
  • 20
  • 19
1

I spent half a day wracking my brains on this and the only solution I could find was to create a new VirtualHost with the DocumentRoot set to the user's home directory.

Saurabh Nanda
  • 6,373
  • 5
  • 31
  • 60
-1

Allow overrides in you configuration file for your home directories.

Andrew Sledge
  • 10,163
  • 2
  • 29
  • 30