Click to See Complete Forum and Search --> : Apache and subdomains problem


Bootsman123
08-23-2005, 07:33 AM
I'm trying to get wildcard DNS to work, so test.domain.nl and test2.domain.nl are getting redirected to domain.nl/index.php?subdomain=%1.

Therefore I've placed this into my vhost.conf:

ServerAlias *.domain.nl

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.nl$
RewriteCond %{HTTP_HOST} !^www\.domain\.nl$
RewriteRule (.*)
http://www.domain.nl/index.php?subdomain=%1 [P,QSA,L]
</IfModule>


But for some reason this isn't working.

Thanks in advance.

Scleppel
08-24-2005, 06:41 AM
Are you putting the mod_rewrite code in the virtualhost tags? I think should be in the directory tags.

I also changed the P to an R for redirect, I'm not sure if you wanted it to be proxied or not.

RewriteRule (.*) http://domain.nl/index.php?subdomain=%1 [R,QSA,L]

Bootsman123
08-24-2005, 11:06 AM
Actually I didn't put it between any tags at all. I just put it plain into vhost.conf.

Scleppel
08-24-2005, 11:21 AM
It should be something like:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName domain.nl
ServerAlias *.domain.nl
DocumentRoot /document/root
</VirtualHost>

<Directory /document/root>
Options All
AllowOverride All
<IfModule mod_access.c>
Order Deny,Allow
Allow from all
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*).domain.nl$
RewriteCond %{HTTP_HOST} !^www.domain.nl$
RewriteRule (.*) http://www.domain.nl/index.php?subdomain=%1 [R,QSA,L]
</IfModule>
</Directory>

You might have some of that (the top line) already, if you already have working virtual hosts.

Bootsman123
08-24-2005, 03:29 PM
I'll try it out.