Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Mon Dec 03, 2007 10:01 pm 
Offline
Senior Newbie

Joined: Wed Nov 28, 2007 12:09 pm
Posts: 5
Location: San Francisco, CA
I have an old account on with a provider that gives me the opportunity to redirect non-www requests to their www counterparts (without doing it with .htaccess files). I want to mimic that option.

Lets take "domain.com" as an example.

(This is what I want to happen, not how it works right now)
domain.com redirects to www.domain.com but reads from /domain.com (same as domain.com would without the re-direct).

subdomain.domain.com reads from /subdomain.domain.com

I don't want to set up VirtualHosts for every single domain/subdomain, but I'm starting to think this is the only way. A lot of examples uses VirtualDocumentRoot /%0- and that would work for the subdomains but not domain.com as it would result in apache looking for /www.domain.com

Is what I'm trying to do possible or am I just trying to be much too dynamic for no good reason?


Top
   
 Post subject:
PostPosted: Tue Dec 04, 2007 4:53 am 
Offline
Senior Member

Joined: Wed Oct 20, 2004 8:55 am
Posts: 120
Code:
<VirtualHost ip:80>
ServerName domain.com
ServerAlias www.domain.com

Other stuff in here as required

</VirtualHost>


Should get the first bit happening for you.


Top
   
 Post subject:
PostPosted: Tue Dec 04, 2007 1:16 pm 
Offline
Senior Newbie

Joined: Wed Nov 28, 2007 12:09 pm
Posts: 5
Location: San Francisco, CA
Looks like the direction I was heading myself, this is how I've currently set it up, any sugestions are welcome.

../sites-available/default looks like this:
Code:
DocumentRoot /sites
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

<Directory /sites>
        Options ExecCGI -Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
        AddHandler fcgid-script .php
        FCGIWrapper /usr/lib/cgi-bin/php5 .php
</Directory>

NameVirtualHost *:80
<VirtualHost *:80>
        DocumentRoot /sites/default/public_html
</VirtualHost>


And then for each domain I do this:
Code:
<VirtualHost *:80>
        ServerName domain.com
        ServerAlias www.domain.com

        RewriteEngine On
        RewriteCond %{HTTP_HOST} ^domain\.com$
        RewriteRule (.*) http://www.domain.com [R=301,L]

        DocumentRoot /sites/domain.com/public_html
</VirtualHost>
<VirtualHost *:80>
        ServerName domain.com
        ServerAlias *.domain.com
        VirtualDocumentRoot /sites/%0/public_html
</VirtualHost>


Top
   
 Post subject:
PostPosted: Tue Dec 04, 2007 8:55 pm 
Offline
Senior Member

Joined: Sat Jun 05, 2004 12:49 am
Posts: 333
http://gentoo-wiki.com/Apache_Modules_mod_vhost_alias

Could probably be applied to other distributions


Top
   
 Post subject:
PostPosted: Wed Dec 05, 2007 1:10 pm 
Offline
Senior Newbie

Joined: Wed Nov 28, 2007 12:09 pm
Posts: 5
Location: San Francisco, CA
OverlordQ wrote:
http://gentoo-wiki.com/Apache_Modules_mod_vhost_alias

Could probably be applied to other distributions

Thanks for the link, the problem with that one is that example.com and www.example.com gets their own directories.
Too bad you can't do if (%-3.0 == "www") { $dir == "non-www-dir")
;)


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 5 guests


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

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group