Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Apache dynamic vhosts www prefix problem
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Jabbas
n00b
n00b


Joined: 23 Jun 2003
Posts: 22
Location: Poland, Cracow

PostPosted: Thu Sep 02, 2004 11:39 am    Post subject: Apache dynamic vhosts www prefix problem Reply with quote

Hi!

I've a gentoo server with apache2 and dynamic vhosts, it's cool&simple.
But i have no idea how to make apache to automaticly add www. prefix for domain.
Yes, i can make symlink for this dir, but it is ugly and not secure.

In short: I want to make apache2 to access /var/www/www.domain.tld when a webclient is asking for content for www.domain.tld or domain.tld

I've searched the web, forums, maybe i'm dumb but i cannot find anything automagic to do that.
_________________
Half my life is in books' written pages
Live and learn from fools and from sages
You know it's true
All the things you do, come back to you

Greetings!
JaBBaS
Back to top
View user's profile Send private message
keli
Apprentice
Apprentice


Joined: 18 Jul 2003
Posts: 210
Location: TgMures, RO

PostPosted: Thu Sep 02, 2004 6:10 pm    Post subject: Reply with quote

Vhere your vhosts are configured, you can have both a ServerName directive, and a ServerAlias directive. You can use those, to direct Apache to the same directory. If you'd like to change the URL displayed in the addressbar too, you could use a Rewrite rule.

somethin like this:

Code:

NameVirtualHost *
<VirtualHost *>
       ServerName www.domainname.tld
       ServerAlias domainname.tld
       DocumentRoot /var/www/www.domain.tld
          RewriteEngine On
          RewriteCond %{HTTP_HOST}   !^www\.domainname\.tld [NC]
          RewriteCond %{HTTP_HOST}   !^$
          RewriteRule ^/(.*)         http://www.domainname.tld/$1 [L,R]
</VirtualHost>


(more details on Rewrite rules in the Apache rewrite guide )
_________________
"The future masters of technology will have to be lighthearted and intelligent. The machine easily masters the grim and the dumb."
Marshall McLuhan, 1969
Back to top
View user's profile Send private message
Jabbas
n00b
n00b


Joined: 23 Jun 2003
Posts: 22
Location: Poland, Cracow

PostPosted: Fri Sep 03, 2004 7:59 am    Post subject: Reply with quote

keli wrote:
Vhere your vhosts are configured, you can have both a ServerName directive, and a ServerAlias directive. You can use those, to direct Apache to the same directory. If you'd like to change the URL displayed in the addressbar too, you could use a Rewrite rule.


Yes, i can ServerName and ServerAlias. It's not a problem. But i have dynamic vhosts so i do not use <VirtualHost> directive. It's like this:

Code:
# include the server name in the filenames used to satisfy requests
 VirtualDocumentRoot /www/hosts/%0/docs
 VirtualScriptAlias /www/hosts/%0/cgi-bin


You can read about this here: http://httpd.apache.org/docs-2.0/vhosts/mass.html

I have lot of domains and pages... this is simple and very cool to configure but this www prefix....
I can use %2+ or something instead of %0 but, when i had mail.domain.com apache2 searches for domain.com dir...

I have to strip only www. prefix from the begining of domain....

P.S.: My english can be bad. Sorry for that
_________________
Half my life is in books' written pages
Live and learn from fools and from sages
You know it's true
All the things you do, come back to you

Greetings!
JaBBaS
Back to top
View user's profile Send private message
Circuitsoft
Tux's lil' helper
Tux's lil' helper


Joined: 14 Jul 2004
Posts: 112

PostPosted: Mon Nov 29, 2004 8:52 am    Post subject: Reply with quote

%-2 instead of %0
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum