PDA

View Full Version : Problem with subdomains



Fiola
03-15-2009, 05:29 PM
Hi for all in Hostmonster!
I am new on HostMonster and thats why i must ask you for some things.

1. I want to separate root of main domain to other subfolder. Thats i have it done. But there is second problem.

2. When I have created a subdomain - it is accessible from:

- www.test.fiolasoft.net

and also from

- www.fiolasoft.net/test/

I want to disable second "feature". Because i want use mod_rewrite on my site. (where is coolURIs) - thats means, i do not want to redirect - but i want to disable access from www.fiolasoft.net/test/ to showing contain of subdomain.

Don't tell me that it's not possible. I already know that :)

I cant use my web-applications on this hosting until I solve this problem. Because some subdomains are equals for name of COOL-URIs in my applications.

Thanks for all help. And sorry for my english. It is my second language :).

Falcon1986
03-15-2009, 06:10 PM
1. I don't quite understand what you are asking in your first question, but here goes. Your root web directory is the public_html directory. If you create subdomains or addon domains they will have to physically reside in subdirectories of the main public_html directory.

2. I don't see how you can achieve the second part without some redirecting involved. You will need to insert the following statement into your root web directory's .htaccess file.


Options +FollowSymlinks
RewriteEngine On

# Redirect subdirectory to subdomain
RewriteCond %{HTTP_HOST} !^test\.fiolasoft\.net
RewriteRule (.*) http://test.fiolasoft.net/$1 [L,R=301]

If you do not want to retain the www in front of URLs pointed to the subdomain, use this slightly modified version:


Options +FollowSymlinks
RewriteEngine On

# Remove www
RewriteCond %{HTTP_HOST} ^www\.(.+)$
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

# Redirect subdirectory to subdomain
RewriteCond %{HTTP_HOST} !^test\.fiolasoft\.net
RewriteRule (.*) http://test.fiolasoft.net/$1 [L,R=301]

Fiola
03-15-2009, 06:33 PM
Falcon1986: I would like to thank you so much for your help. But this example i find, when i search this forum. This isnt solve my problem. There is thing.

I want this:

The main domain will be separate from subdomains. http://fiolasoft.net or
http://www.fiolasoft.net/ show content in public_html/www/. Thats works
fine.

The subdomain test have folder: public_html/test/ ... and i want to separate it. I do not want to automatically fetch fiolasoft.net to all domain names wich are identical with subdomains. Because, for me, there are two different addresses. I want show for fiolasoft.net/test/ something else than for
test.fiolasoft.net ...

I do not redirect on subdomain :).


Thanks ;),
Filip

Falcon1986
03-15-2009, 07:01 PM
The subdomain test have folder: public_html/test/ ... and i want to separate it. I do not want to automatically fetch fiolasoft.net to all domain names wich are identical with subdomains. Because, for me, there are two different addresses. I want show for fiolasoft.net/test/ something else than for
test.fiolasoft.net ...

I'm still confused. Perhaps someone else may be able to get something that I'm missing.

Are you saying, for example, that you want access to fiolasoft.net/test/ be able to display a completely different web page than would be displayed if one accessed test.fiolasoft.net? If you are then I'm not sure that is possible, since your subdomain already points to that subdirectory. To you they may seem different, but Apache is interpreting them as the same thing. Why not create a different subdirectory?

Fiola
03-15-2009, 07:14 PM
I am fully convinced, there must be way.

When i create on my apache2 at home vhost - i have way to configure it. There is the way.

Imagine, for example: i want to have images.fiolasoft.net as subdomain
for my images gallery and also i will using on fiolasoft.net folder images for web-layout. There are two different contents in each folder. I want separate it. There must be way, how config that. On my last hosting. On each hosting, where i was it was exactly like my description.

This is my first meet with something, what have Host Monster :). I really havent anywhere else this problem.


I want you show example on application in use:

When you're go on: http://www.indian.fiolasoft.cz ... there is a normal web.
But when you're go on: http://www.fiolasoft.cz/indian/ ... there is something else, isnt it? Thats normal server behavior. No like redirecting automatically to subdomains :).

danaketh
03-15-2009, 07:52 PM
Solved! Here's the solution ot your problem. Maybe somebody else will find it usefull in future :)


# main domain
RewriteCond %{HTTP_HOST} ^(www.)?fiolasoft.net$
RewriteCond %{REQUEST_URI} !^/www/
RewriteRule ^(.*)?$ /www/$1

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# test.fiolasoft.net
RewriteCond %{HTTP_HOST} ^test.fiolasoft.net$
RewriteCond %{REQUEST_URI} !^/test/
RewriteRule ^(.*)?$ /test/$1

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

You have to add every subdomain by hand but I think you can handle that ;)

Fiola
03-15-2009, 08:01 PM
Ah! Thanks very much Danaketh!

This is exactly what i want! :) ... Works great, simple and quick script...

Thanks, thanks, thanks! :)

Falcon1986
03-15-2009, 08:58 PM
Wow! That's awesome. Thanks to also pointing us to a working example for clarification.

amber19
03-17-2009, 08:27 AM
it looks like you need to remove the default page