Forum Moderators: phranque

Message Too Old, No Replies

Multiple site hosting - forbid access to subfolders

multiple accounts, multiple sites, forbid subfolders

         

anthylon

11:13 am on Feb 23, 2009 (gmt 0)

10+ Year Member



Hello,

I have hosting package allows me to host multiple domains. Now I am hosting one few sites: friends and one is for NGO.

All domains are pointed to subfolder example: mydomain.com/site1, mydomain.com/site2 etc.

I just discovered that via certain php coding they can easy access to the root.:o I am very worried - they could erase something by mistake. They can access to the root only when opening their site using: mydomain.com/site1/. If they going thought their domain than they can't access to the root.:(

I don't know much about apache directives but I am learning.:)

Could someone tell me is how to forbid people from accessing to their site over my domain (mydomain.com/site/). I want them to go over their domain (which is pointed to their folder) or via site.mydomain.com.

Thank you.;)

jdMorgan

5:56 pm on Feb 23, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Simply redirect direct client request for /site 1 to the correct domain root, instead of trying to forbid access. This takes care of the problem *and* prevent duplicate content issues in search engines.

The mod_rewrite code to do that is included in many posts here; Try searching WebmasterWorld for "redirect direct client requests" as a quoted string. Some threads are about mapping subdomains to subfolders, others are about mapping multiple "add=on" domains to subfolders. Your problem is the second of these.

Jim

anthylon

6:40 am on Feb 24, 2009 (gmt 0)

10+ Year Member



Thank you jdMorgan!

I spent hours trying to understand whole concept.

Finally here is what I made:


Options -Indexes +FollowSymLinks
IndexIgnore */*
DirectoryIndex index.php index.html index.htm
RewriteEngine On
redirectMatch permanent ^/subdomain(/.+)?/?$ http://subdomain.mydomain.com$1/

Be advised that I am still learning and trying to understand how it works.

Is this what I am using proper solution? As far as I could test - it works but I am not sure is this correct way.

Thank you for your help:)