Multiple fixed subdomains

Using a single web hosting account to host multiple sites

Multiple fixed subdomains

Postby ivanatora » Wed Oct 31, 2007 10:20 am

I have wildcard DNS set up, and my first subdomain with mod_rewrite is working! However, I have a problem with the second one :)
I'm using the following .htaccess file:
Code: Select all
RewriteEngine on
RewriteCond %{HTTP_HOST} ivan.domain.info [NC]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^$ /blog/ [QSA,L]

RewriteCond %{HTTP_HOST} forum.domain.info [NC]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^$ /forum/ [QSA,L]

I'm doing something wrong, because I get error 500 when trying accessing the second subdomain.
I tried replacing the second block with a single rule:
Code: Select all
RewriteRule ^forum.domain.info$ /forum/ [QSA,L]

but I'm still getting a 500.
What am I doing wrong?
ivanatora
 
Posts: 9
Joined: Tue Jul 17, 2007 5:38 am

Postby richardk » Wed Oct 31, 2007 1:00 pm

It looks fine.

Do you get a 500 error when accessing the sub domain if you remove all the mod_rewrite?
Do you get a 500 error when you access domain.info/forum/?
What does your error log say about the error?
Do you get a 500 error for the forum sub domain if you change the order of the rules?

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?ivan\.domain\.info$ [NC]
RewriteRule ^$ /blog/ [QSA,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?forum\.domain\.info$ [NC]
RewriteRule ^$ /forum/ [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby ivanatora » Wed Oct 31, 2007 1:33 pm

In order to check your stuff, I renamed .htaccess to .htaccess2 and tried accessing the second subdomain.
It was there (with no rewrite rules to execute) and it did open it!

Is it possible it could take some times to the httpd server to 'reload' rules from .htaccess files?
If so - how can I control this?
ivanatora
 
Posts: 9
Joined: Tue Jul 17, 2007 5:38 am

Postby richardk » Wed Oct 31, 2007 1:40 pm

In order to check your stuff, I renamed .htaccess to .htaccess2 and tried accessing the second subdomain.
It was there (with no rewrite rules to execute) and it did open it!

Did the ivan sub domain work?

Is it possible it could take some times to the httpd server to 'reload' rules from .htaccess files?
If so - how can I control this?

Not by default as far as i know. Your host might have something special, though (ask them).
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby ivanatora » Wed Oct 31, 2007 2:31 pm

So here is the situation:
if I remove .htaccess the 'forum' subdomain is working, but the 'ivan' subdomain is not working.

I can't see anything in the error_log. Maybe I have to turn on RewriteLog? Shoud I write it in .htaccess or directly into httpd.conf. If I add it into .htaccess I get 500 on all subdomains and this in error_log:
Code: Select all
[Thu Nov  1 00:28:26 2007] [alert] [client 85.187.229.182] /home/tu/www/.htaccess: RewriteLog not allowed here

I have AllowOverride All for that directory.

And I can access domain.com/forum/ freely with no errors.

If I change the order of the rules, 'ivan' is working and the 'forums' is still not working - no change in the situation.
ivanatora
 
Posts: 9
Joined: Tue Jul 17, 2007 5:38 am

Postby richardk » Wed Oct 31, 2007 4:01 pm

You don't need mod_rewrite for the forum sub domain. The server must be set up to "rewrite" sub domains where the sub domain is the same as the directory.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby ivanatora » Thu Nov 01, 2007 6:09 am

I don't want to allow every subdomain to be forwarded to every folder in my document root, becouse someone could try admin.domain.info and get into the admin/ dir, for example. I want only a couple of subdomains to be forwarded.
ivanatora
 
Posts: 9
Joined: Tue Jul 17, 2007 5:38 am

Postby richardk » Thu Nov 01, 2007 12:36 pm

Then you need to find out what's doing it (the forum sub domain rewrite) and stop it. Ask your host about it.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 33 guests

cron