Dragen Posted December 1, 2010 Share Posted December 1, 2010 Hi, I have a sub-domain set up, which links to a folder in the root directory of my main domain: main_root/sub_domain/ What I am trying (and failing) to do is to create a .htaccess entry in the root directory of the main domain (main_root), where the main domain website is, to stop users accessing the sub-domain via the relative path (ie; mydomain.com/sub_domain/) and instead only allowing access if they access it like so; sub_domain.mydomain.com Is this possible? I would preferably send them a 404 not found, rather than 403 or anything else. At the moment I have resorted to detecting the host, from within a .htaccess file in the sub-directory and if it is that of the main domain, then re-direct to the index page of the main domain, but I really need to be able to do this without editing the .htaccess of the sub-domain. Just for reference, the code I'm using in my sub-domain is as follows: RewriteCond %{HTTP_HOST} !^(www.)?sub_domain.maindomain.com [NC] RewriteRule ^(.*)$ / [R,L] Any help would be more than appreciated! Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.