logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: rewrite ~userdir to subdomain
Author
blasto



Joined: 21 Mar 2006
Posts: 3

PostPosted: Wed 30 Sep '15 13:37    Post subject: rewrite ~userdir to subdomain Reply with quote

Hi there,

I thought this would be an easy find but no luck so far...

I run apache to serve (with mod_userdir) micro user sites as:
portal.company.com/~user1
portal.company.com/~user2 ... so on

each user already has a virtualhost as user1.company.com pointing their home/www directory
So I would like portal.company.com/~user1 to be rewritten as user1.company.com

What is the proper way to use mod_rewrite in this case?

Thanks
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Wed 07 Oct '15 13:40    Post subject: Reply with quote

Very simple, just disable the mod-userdir, and add a ServerAlias

Code:
<VirtualHost *:80>
    ServerName www.example.com
    DocumentRoot /var/www/
</VirtualHost>
<VirtualHost *:80>
    ServerName *.example.com
    ServerAlias *.example.com
    VirtualDocumentRoot /home/%1/www
</VirtualHost>
Back to top


Reply to topic   Topic: rewrite ~userdir to subdomain View previous topic :: View next topic
Post new topic   Forum Index -> Apache