Sign up ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Possible Duplicate:
How do I prevent access to an add-on domain's root directory from main hosting domain name

I am hosting a webshop with OpenCart and its current URL is e.g.
I have created two subdomains ( and ) and both subdomains are already working as they should. However, can I restrict direct access to while leaving all the files (index.php, etc.) there?
Since both subdomains are pointing to, I thought this would restrict all access.

So in the end, I would like my two shops to be accessable through and, but not while leaving all the files in

share|improve this question

marked as duplicate by paulmorriss, danlefree Sep 12 '12 at 0:45

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers 2

up vote 2 down vote accepted

You can do it with the following rule. This file would need to be placed in your /shop/ subdirectory.

RewriteEngine on
RewriteBase / 

#if not already
RewriteCond %{HTTP_HOST} !^shop\.mydomain\.com$ [NC] 
#if request is for shop/, go to
RewriteRule ^shop/$ [L,NC,R=301] 

For obvious reasons, you can't redirect a person to two places at once (you need to choose either or Once you have done the above, you can always do a manual redirect from the to The rule can also be used if you wanted to setup a second shop.

share|improve this answer

It's always bad practice to leave operational things in web accessible folder.

But you can always place a .htaccess file in the shop folder to redirect the traffic to another address.

share|improve this answer
Thank you for your answer. Where can I look up how to fill this .htaccess file? I'm rather new to configuring a server – MechMK1 Jun 26 '12 at 12:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.