View previous topic :: View next topic |
Author |
Message |
Jabbas n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 23 Jun 2003 Posts: 22 Location: Poland, Cracow
|
Posted: Thu Sep 02, 2004 11:39 am Post subject: Apache dynamic vhosts www prefix problem |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
keli Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
![](images/avatars/17164059053f17ba3ec6d76.jpg)
Joined: 18 Jul 2003 Posts: 210 Location: TgMures, RO
|
Posted: Thu Sep 02, 2004 6:10 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
Jabbas n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 23 Jun 2003 Posts: 22 Location: Poland, Cracow
|
Posted: Fri Sep 03, 2004 7:59 am Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
Circuitsoft Tux's lil' helper
![Tux's lil' helper Tux's lil' helper](/images/ranks/rank_rect_1.gif)
Joined: 14 Jul 2004 Posts: 112
|
Posted: Mon Nov 29, 2004 8:52 am Post subject: |
|
|
%-2 instead of %0 |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|
|
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
|
|