Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
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.
| |
|
Topic: Issues with dynamic subdomains (mod_rewrite/htaccess?) |
|
Author |
|
timthetortoise
Joined: 24 Oct 2007 Posts: 2
|
Posted: Wed 24 Oct '07 6:28 Post subject: Issues with dynamic subdomains (mod_rewrite/htaccess?) |
|
|
Hi all, first post here so sorry if I break any rules with this post. I've searched up and down Google but haven't searched the board yet, so if I need to do that, kindly let me know so I don't waste anyone's time
Basically, I am trying to do dynamic subdomains with Apache2. My DNS registrar is Godaddy, and I am using their nameservers. The idea of what I'm trying to do is, have foo.bar.org access bar.org/sites/foo, and have it still show up as foo.bar.org. With an invalid folder, for some reason, this works and shoots me to /sites, like (I hope) it should. However, if I use a valid one (for instance, valid.bar.org), it redirects to www.bar.org/sites/valid without masking the URL. Another thing I noticed is that if I go to bar.org, it will automatically append www for the subdomain, which is not something that I like to happen. I've gone through my .htaccess file a dozen times and can't seem to lick this, so if anyone can provide suggestions on what to change or where to look for what may be the real problem, I'd be forever grateful, as I have been fighting with this for a few hours now. Here are the relevant files
.htaccess
Code: |
RewriteEngine On
RewriteCond ${HTTP_HOST} !^www\.bar\.org$ [NC]
RewriteCond ${HTTP_HOST} ^([a-zA-Z0-9]*)\.bar\.org$ [NC]
RewriteRule ^(.*)$ /var/www/bar\.org/sites/%1/ [NC,L]
|
200-bar.org.conf (softlinked in sites-enabled)
Code: |
<VirtualHost *:80>
ServerAlias *bar.org
DocumentRoot /var/www/bar.org
DirectoryIndex index.htm index.php index.html
CustomLog /var/log/apache2/bar.org-access.log combined
ErrorLog /var/log/apache2/bar.org-error.log
</VirtualHost>
|
Godaddy.com A record
mods-enabled
Code: |
lrwxrwxrwx 1 root root 28 2007-10-02 15:31 alias.load -> ../mods-available/alias.load
lrwxrwxrwx 1 root root 33 2007-10-02 15:31 auth_basic.load -> ../mods-available/auth_basic.load
lrwxrwxrwx 1 root root 33 2007-10-02 15:31 authn_file.load -> ../mods-available/authn_file.load
lrwxrwxrwx 1 root root 36 2007-10-02 15:31 authz_default.load -> ../mods-available/authz_default.load
lrwxrwxrwx 1 root root 38 2007-10-02 15:31 authz_groupfile.load -> ../mods-available/authz_groupfile.load
lrwxrwxrwx 1 root root 33 2007-10-02 15:31 authz_host.load -> ../mods-available/authz_host.load
lrwxrwxrwx 1 root root 33 2007-10-02 15:31 authz_user.load -> ../mods-available/authz_user.load
lrwxrwxrwx 1 root root 32 2007-10-02 15:31 autoindex.load -> ../mods-available/autoindex.load
lrwxrwxrwx 1 root root 26 2007-10-02 15:31 cgi.load -> ../mods-available/cgi.load
lrwxrwxrwx 1 root root 26 2007-10-02 15:31 dir.conf -> ../mods-available/dir.conf
lrwxrwxrwx 1 root root 26 2007-10-02 15:31 dir.load -> ../mods-available/dir.load
lrwxrwxrwx 1 root root 26 2007-10-02 15:31 env.load -> ../mods-available/env.load
lrwxrwxrwx 1 root root 27 2007-10-02 15:31 mime.load -> ../mods-available/mime.load
lrwxrwxrwx 1 root root 34 2007-10-02 15:31 negotiation.load -> ../mods-available/negotiation.load
lrwxrwxrwx 1 root root 27 2007-10-02 15:31 php5.conf -> ../mods-available/php5.conf
lrwxrwxrwx 1 root root 27 2007-10-02 15:31 php5.load -> ../mods-available/php5.load
lrwxrwxrwx 1 root root 40 2007-10-23 17:58 rewrite.load -> /etc/apache2/mods-available/rewrite.load
lrwxrwxrwx 1 root root 31 2007-10-02 15:31 setenvif.load -> ../mods-available/setenvif.load
lrwxrwxrwx 1 root root 29 2007-10-02 15:31 status.load -> ../mods-available/status.load
lrwxrwxrwx 1 root root 30 2007-10-17 08:08 userdir.load -> ../mods-available/userdir.load
lrwxrwxrwx 1 root root 34 2007-10-23 17:47 vhost_alias.load -> ../mods-available/vhost_alias.load
|
I've also tried unloading/reloading modules and purposely generating errors to make sure that .htaccess was actually being called, and indeed it is. I'm just drawing blanks here and am apparently not proficient enough with Apache yet to see where this problem is. Thanks in advance for any help you can offer! |
|
Back to top |
|
timthetortoise
Joined: 24 Oct 2007 Posts: 2
|
Posted: Wed 24 Oct '07 15:50 Post subject: |
|
|
Just an update, I fixed it this morning by using mod_vhost_alias instead, but I'm still interested in why it might have been doing this. Here's my config if anyone else has the same problem and stumbles upon this thread
Code: |
<VirtualHost *:80>
ServerAlias bar.org www.bar.org
DocumentRoot /var/www/bar.org
DirectoryIndex index.htm index.php index.html
CustomLog /var/log/apache2/bar.org-access.log combined
ErrorLog /var/log/apache2/bar.org-error.log
</VirtualHost>
<VirtualHost *:80>
ServerAlias *.bar.org
DirectoryIndex index.htm index.php index.html
VirtualDocumentRoot /var/www/bar.org/sites/%1
CustomLog /var/log/apache2/sub.bar.org-access.log combined
ErrorLog /var/log/apache2/sub.bar.org-error.log
</VirtualHost>
|
|
|
Back to top |
|
|
|
|
|
|