I have some subdomains setup on my site. The redirection works as follows: domain.com/sites/blue > blue.domain.com domain.com/sites/green > green.domain.com etc. The subdomains are working fine, but I was wondering if there is something I can put into my htaccess file to prevent people from accessing the site by typing in domain.com/sites/blue. I want a (301?) redirect to blue.domain.com. How would I do this? Thanks for your help.
I can't imagine why though. What's the big deal if they type in the full address - the page will still come up! I think people don't realize what the web is. It's just files sitting on a hard drive on some unix computer somewhere that you connect to like your own harddrive. Sure you can make it redirect, but you can't lock everything down or else people wouldn't be able to access it. If you're not ready for people to see what you've got there, maybe you aren't ready to put this content online.
As a matter of fact, Im running a script that is setup to run off the subdomain. All of the paths are setup to the subdomain. The script will not work when the site is accessed from its path from the main domain. So, instead of trying to tell everyone how the Internet works, why not move on if you don't have an answer and spam someone else's thread?
The solution to your problem depends on the specific needs of the script. Could you give more details about its workings? BTW, you say that "I want a (301?) redirect to blue.domain.com.". What is impeding you of doing it?