0

basically i have a web server set up where all sites are in /var/www but i want to be able to do development in ~/public_html/sitename so i set userdir's up in apache but the links still goto the /var/www directories pages.

I know i could go in and change all the links, but i think an htaccess would be easier.

So my question is, is it possible to say:

We have a folder in my public_html on home which is accessed via example.com/~jackyyll/project

I want all requests from that project to be redirected to ~/jackyyll/project/request_here

I've tried some things in the .htaccess but nothing is working.

Thanks

marcaddeo
  • 177
  • 2
  • 3
  • 12
  • I think you should really be looking into getting [mod_userdir](http://httpd.apache.org/docs/2.1/mod/mod_userdir.html) working as opposed to using mod_rewrite. – Jon Lin Mar 16 '12 at 18:21

1 Answers1

0

If you don't want to use mod_userdir, a simple AliasMatch can do the trick. Here is what I use to map www.kylheku.com/~kaz/ to /home/kaz/public-www/, et cetera, straight from my httpd.conf:

# /~user/blah goes to /home/user/public-www/blah
AliasMatch ^/~([a-z]+)/(.*) /home/$1/public-www/$2

# /~user and goes to /home/user/public-www/
AliasMatch ^/~([a-z]+)$ /home/$1/public-www/

AliasMatch has some capabilities resembling mod_rewrite, except, just like Alias what it does is it takes URL's coming into the server and maps them to paths. The output is not re-injected into the request processing chain. Any URL mapped by Alias or AliasMatch bypasses the VirtualHost-s and their docroots. It's like a special exception mechanism.

The .htaccess in the user's public-www directory works just fine. I have RewriteRules there and other cruft.

Of course, this is a lot simpler than mod_userdir. It maps all possible usernames to all possible userdir directories, whether or not they exist. mod_userdir has more bells and whistles, like restricting which users have a userdir, and alternative userdirs certain users.

Kaz
  • 55,781
  • 9
  • 100
  • 149