怎样主域根到子文件夹和prevent访问从主要领域,同时转移到插件域? [英] How do I shift main domain root to subfolder and prevent access to addon domains from main domain at the same time?

查看:147
本文介绍了怎样主域根到子文件夹和prevent访问从主要领域,同时转移到插件域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我又一次转向,所以当我在我束手无策。我的一个客户端上运行一个单一的托管计划三个独立的网站。 我需要做的是主域名的内容转移到子文件夹和主域名链接到它,这样

Once more I turn to SO when I am at my wits end. A client of mine is running three separate websites on a single hosting plan. What I need to do is shift the main domain contents to a sub-folder and link the main domain to it so that

maindomain.com/

实际上被链接到

actually gets linked to

/maindomain/

这我得到了正与

RewriteCond %{HTTP_HOST} ^(www.)?maindomain.com/$ 
RewriteCond %{REQUEST_URI} !^/maindomain/ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /maindomain/$1  
RewriteCond %{HTTP_HOST} ^(www.)?maindomain.com$ 
RewriteRule ^(/)?$ maindomain/index.html [L]

第二部分是问题。我现在需要prevent插件域domainA中和域B从主domain.To被访问使问题更加复杂,domainA中运行了CakePHP,并即doma​​inB正在运行一个自定义的框架,这是完全依赖于它的.htaccess

The Second part is the problem. I now need prevent addon domains domainA and domainB from being accessed from the main domain.To make matters more complicated, domainA is running cakePHP and domainB is running a custom framework which is totally dependent on its .htaccess

域存在于根目录的子文件夹,

the domains lie in sub-folders of webroot as

/domainA/

/domainB/

我尝试以下,但它并没有prevent进入附加域。

I tried the following but it didn't prevent access to the add-on domains.

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

我真的可以用什么做的一些见解。

I could really use some insight on what to do.

推荐答案

把这个规则为在这两个是第一行 /domainA/.htaccess /domainB/.htaccess 文件

Place this rule as very first rule in both /domainA/.htaccess and /domainB/.htaccess files:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?maindomain\.com$ [NC]
RewriteRule ^ - [L,R=404]

这篇关于怎样主域根到子文件夹和prevent访问从主要领域,同时转移到插件域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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