Jump to content

Hide Subdomain Folder


WhiskeyJack

Recommended Posts

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

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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". :)

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...