Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 使用CPanel将域移动到子目录_Apache_.htaccess_Redirect_Rewrite_Cpanel - Fatal编程技术网

Apache 使用CPanel将域移动到子目录

Apache 使用CPanel将域移动到子目录,apache,.htaccess,redirect,rewrite,cpanel,Apache,.htaccess,Redirect,Rewrite,Cpanel,我最近把我的几个域移到了GoDaddy,目前正努力为每个域正确设置目录结构。我的每个插件域都位于public_html/下自己的目录中。此外,我想将我的主域移动到它自己的子文件夹中以保持整洁。因此,我的目录设置如下所示: public_html/ primarydomain/ addondomainA/ addondomainB/ addondomainC/ 我在public_html下设置.htaccess文件,如下所示: RewriteEngine on

我最近把我的几个域移到了GoDaddy,目前正努力为每个域正确设置目录结构。我的每个插件域都位于public_html/下自己的目录中。此外,我想将我的主域移动到它自己的子文件夹中以保持整洁。因此,我的目录设置如下所示:

public_html/
    primarydomain/
    addondomainA/
    addondomainB/
    addondomainC/
我在public_html下设置.htaccess文件,如下所示:

RewriteEngine on

# Rewrite direct addondomain access to their proper domains
RedirectMatch ^/addondomainA.com/(.*)$ http://addondomainA.com/$1 
RedirectMatch ^/addondomainB.com/(.*)$ http://addondomainB.com/$1 
RedirectMatch ^/addondomainC.com/(.*)$ http://addondomainC.com/$1

# Rewrite primary domain access to the primarydomain/ folder
RewriteCond %{HTTP_HOST} ^(www.)?primarydomain.com/
RewriteCond %{REQUEST_URI} !^/primarydomain/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /primarydomain/$1
RewriteCond %{HTTP_HOST} ^(www.)?primarydomain.com$ 
RewriteRule ^(/)?$ primarydomain/index.html [L]
插件域重定向工作正常,如果我尝试访问primarydomain.com,请求会正确地重写到primarydomain/子目录。但是,如果我尝试访问primarydomain.com/primarydomain,则不会重写任何内容(据我所知),用户可以直接访问该页面。我想禁止对primarydomain/文件夹的所有直接访问请求,但我尝试的方法似乎都不起作用。我认为:

RewriteCond %{REQUEST_URI} !^/primarydomain/
会做些什么,但似乎对行为没有影响。同样,两者:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
…如果删除,似乎没有任何效果。我甚至尝试在顶部添加第四个RedirectMatch子句,希望在插入文件夹时捕获文件夹名称,但这会导致重定向循环,好像它在无序处理命令。我已经吞食了所有关于堆栈溢出的答案,但没有一个能解决这个问题。我已经尝试了多个新的浏览器,并且非常确定这不是缓存问题


有人知道如何完成这项看似超基本的任务吗?有什么是我忽略的吗?提前感谢。

您可以尝试使用cname返回到正确的目录(cPanel中高级dns中的cname)