PDA

View Full Version : Preventing subdomains been accessed from main domain.



Matt
05-17-2008, 06:18 AM
Sorry, I am quite aware of the fact that this has no doubt been answered before, but I'm not really sure how to describe what I'm trying to achieve, and unfortunately search does not yet read my mind :(

My question is as follows:

How can I prevent people accessing my subdomains via mymaindomain.com/thesubdomain?

An example of this is my mail- mail.mattlunn.me.uk is fine, but I can also access it via mattlunn.me.uk/mail - which I don't want to be able to do.

I know this is because the "mail" folder, is in my public_html folder, but I don't know how I can change the structure/ settings correctly in order to disable this.

Many thanks in advance,

Matt Lunn

cstefkivoila
10-28-2008, 05:03 AM
I exactly have the same problem.
Is there a solution?
Is it possible to point the subdomains to another directory outside the public_html folder?

RDM
10-28-2008, 08:15 AM
Add this to the sub-domains .htaccess file



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


Remove www's if you choose not to use them.



Is it possible to point the subdomains to another directory outside the public_html folder?

Short answer, No. At least not without PHP's help.

r2b2
10-28-2008, 03:01 PM
Well you could kind of point the subdomain outside of the directory using symbolic links but I wouldn't recommend it unless you have an intimate knowledge of Linux...