Jump to content

Recommended Posts

Posted

I have setup a subdomain for my site called beta, to put up content I wish to test on the server but not make live to the public. The root folder for the subdomain is public_html/beta. Problem is, if a user goes to /beta instead, they are able to access the content. Is there a way to make the folder visible only to those visiting beta.mysite.com instead of mysite.com/beta?

 

~WhiskeyJack

Posted

This should do what you want. Create a .htaccess file in your beta folder and add the code below:

 

RewriteEngine On
RewriteRule ^/?$ /index.php

 

This will redirect all requests like this:

 

mysite.com/beta

 

to your index.php file while allowing: beta.mysite.com to see the directory index and still allowing file access by name like this:

 

mysite.com/beta/myfile.html

 

EDIT: Nevermind that didn't qet it. I just tried that on one of my subdomains. Go ask your question in this forum under the subforum Apache Configuration. I'm sure somebody there can help you:

 

http://www.codingforums.com/

 

Let me know what they tell you.

 

Posted

If people don't know that the "beta" directory exists, then why would they try and access it? I agree that security is important but this seems to be borderline on paranoia. You can try asking your question here: http://www.thehosthelpers.com as I know there are people there who can give you the htaccess for this.

Posted

You should create your subdomain folders in your /home directory instead of inside /home/public_html. CPanel tries to get you to put your subdomain folders inside /home/public_html, but that is not really a good idea because a subdomain is supposed to be a 'different domain' than your main domain. You should change it manually to create subdomain document roots in your /home directory, its more secure.

Posted

It seems the most elegant solution is:

 

Redirect /beta http://beta.mysite.com

 

 

Thanks for the pointers.

 

~WhiskeyJack

 

You should create your subdomain folders in your /home directory instead of inside /home/public_html. CPanel tries to get you to put your subdomain folders inside /home/public_html, but that is not really a good idea because a subdomain is supposed to be a 'different domain' than your main domain. You should change it manually to create subdomain document roots in your /home directory, its more secure.

 

On that note, is there a way to change the folder a subdomain points to?

 

~WhiskeyJack

Posted

No. You will need to remove your subdomain, then recreate it to point to a folder in the /home directory. After that it will take no more than 24 hours for the changes to apply, because restarting the server is needed.

Posted
No. You will need to remove your subdomain, then recreate it to point to a folder in the /home directory. After that it will take no more than 24 hours for the changes to apply, because restarting the server is needed.

 

Good idea. It seems that is "the most elegant solution". :)

 

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...