WhiskeyJack Posted November 30, 2010 Posted November 30, 2010 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
Wizard Posted November 30, 2010 Posted November 30, 2010 Learn how to work htaccess: http://www.google.com/search?sourceid=chro...&q=htaccess EDIT: Actually, you might be able to get away with changing the folder permissions, but still making the files readable. If this doesn't work, learn htacess.
Byron Posted November 30, 2010 Posted November 30, 2010 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.
rvt Posted November 30, 2010 Posted November 30, 2010 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.
Guest Geoff Posted December 1, 2010 Posted December 1, 2010 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.
WhiskeyJack Posted December 1, 2010 Author Posted December 1, 2010 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
Guest Geoff Posted December 2, 2010 Posted December 2, 2010 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.
Byron Posted December 2, 2010 Posted December 2, 2010 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".
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now