Mobile app version of vmapp.org
Login or Join
Radia820

: How to force user to use subdomain? 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

@Radia820

Posted in: #Subdomain

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. mydomain.com/shop/ I have created two subdomains ( pg.mydomain.com/ and shop.mydomain.com/ ) and both subdomains are already working as they should. However, can I restrict direct access to mydomain.com/shop/ while leaving all the files (index.php, etc.) there?
Since both subdomains are pointing to mydomain.com/shop/, I thought this would restrict all access.

So in the end, I would like my two shops to be accessable through pg.mydomain.com/ and shop.mydomain.com/, but not mydomain.com/shop/ while leaving all the files in mydomain.com/shop/.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Radia820

2 Comments

Sorted by latest first Latest Oldest Best

 

@Heady270

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 shop.mydomain.com
RewriteCond %{HTTP_HOST} !^shop.mydomain.com$ [NC] #if request is for shop/, go to shop.mydomain.com
RewriteRule ^shop/$ shop.mydomain.com [L,NC,R=301]


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

10% popularity Vote Up Vote Down


 

@Twilah146

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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme