如何隔离public_html下的addon域和主域? [英] How can I isolate addon domains under public_html from the main domain?

查看:45
本文介绍了如何隔离public_html下的addon域和主域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Directnic托管多个网站.像许多主机一样,Directonic要求将每个网站放置在/home/< user>/public_html 目录下.这行得通.我的问题是可以从主"域访问某些网站.

I am using Directnic to host multiple websites. Directnic, like many hosts, requires each website to be placed under the /home/<user>/public_html directory. And this works. My problem is that some websites are accessible from the "main" domain.

以下是我的配置示例...

Here is an example of what my configuration looks like...

  1. one.com 与托管计划相关,并直接存储在 public_html 中.

  1. one.com is tied to the hosting plan, and is stored in public_html directly.

two.com 设置为附加域,并存储在 public_html/two 中.

two.com is setup as an addon domain and is stored in public_html/two.

three.com 也被设置为附加域,并存储在 public_html/three 中.

three.com is also setup as an addon domain and is stored in public_html/three.

这一切都按预期工作,所有三个网站都显示三个不同的网站,并且都具有三个不同的文档根目录,因此一切正常.

This all works as expected, all three websites show three different websites and all have three different document roots, so everything works nicely.

我的问题是我可以通过转到 http://one.com/two/来访问 two.com three.com 的文件等,我不想要这个,我希望他们更加孤立.

My problem is that I can access the files for two.com and three.com by going to http://one.com/two/, etc, and I don't want this, I want them to be more isolated.

我可以进行哪些配置以从 one.com 隐藏这些文件?

What configurations might I be able to make to hide these files from one.com?

我的主机使用Apache和cPanel,但是我无权访问特定的conf文件,因此无法创建虚拟主机.也许有些.htaccess骗术?

My host uses Apache and cPanel, but I don't have access to specific conf files, so I can't create virtual hosts. Maybe some .htaccess trickery?

推荐答案

这是cPanel的工作方式.您无法100%隔离它,也无法获得添加虚拟主机条目的配置访问权限.它正在由您的服务提供商进行管理.

This is the way cPanel works. You cannot isolate it 100% and you will not get configuration access to add virtualhost entry. It is being managed by your service provider.

您当然可以限制对HTTP的访问.您可以在子文件夹中添加重写规则(在上面的示例两个文件夹和三个文件夹中).您可以尝试使用以下.htaccess重写规则来防止直接从主域进行访问:

You can certainly restrict the access for HTTP. You can add rewrite rule in your subfoldess (in above example two and three folder). You can try the following .htaccess rewrite rules to prevent direct access from main domain:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?maindomain.com$ [NC]
RewriteCond %{REQUEST_URI} ^/addon1/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/addon2/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/addon3/(.*)$
RewriteRule ^(.*)$ - [L,R=404]

添加以上规则后,您的主域将无法使用HTTP访问插件文件夹.它应该显示404错误页面.

Once you add above rule, your main domain should not be able to access addon folder usin g HTTP. It should show 404 error page.

这篇关于如何隔离public_html下的addon域和主域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆