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: Changing or expanding the userdir mod
Author
seaders



Joined: 01 Nov 2009
Posts: 1

PostPosted: Sun 01 Nov '09 22:54    Post subject: Changing or expanding the userdir mod Reply with quote

Hi guys, I followed the trail from the apache.org site for support to here, so I hope this is the right place to ask for help.

Basically, what I'd like to do is expand the userdir mod. Currently, as normal, the way it works is that it catches any URL that matches http://mydomain.com/~mysername, but I'd also like it to catch any URL that matches http://myusername.mydomain.com. I currently have it working via a few rewrite scripts, but I don't want to be rewriting the URL, I'd much prefer it to attempt to serve from that address, like is done with the regular userdir mod.

Anybody know how I'd be able to do this, or similar? I know how I'd also be able to do this with a few LocationMatches, but they only match the URL after the http_host variable.

Thanks for any help you'd be able to give.
Back to top
James Blond
Moderator


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

PostPosted: Tue 03 Nov '09 12:14    Post subject: Reply with quote

Hi!
You need a wildcard dns to *.mydomain.com
You need to load mod_alias and mod_vhost_alias and mod_userdir


1. Solution
Code:

<VirtualHost *:80>
   ServerName *.mydomain.com
   ServerAlias *.mydomain.com
   VirtualDocumentRoot /home/%1/public_html 
</VirtualHost>


2.Solution (needs mod_rewrite)
Code:

DocumentRoot /webhosts/

[...]

<VirtualHost *>
ServerAlias www.mydomain.com
ServerName www.mydomain.com
RewriteEngine  on
RewriteCond    %{HTTP_HOST}  ^mydomain.com
RewriteRule    ^(.*)$        /www/$1 [L]
RewriteCond    %{HTTP_HOST}  ^www.*
RewriteRule    ^(.*)$        /www/$1 [L]
RewriteCond    %{HTTP_HOST}  ^(.*)\.yourdomain\.com
RewriteRule    ^(.*)$        /%1/$1 [L]
</VirtualHost>


www.yourdomain.com => /webhosts/www/
muon.yourdomain.com => /webhosts/muon/
Back to top


Reply to topic   Topic: Changing or expanding the userdir mod View previous topic :: View next topic
Post new topic   Forum Index -> Apache