简体   繁体   English

使用CPanel将域移动到子目录

[英]Moving domain to subdirectory with CPanel

I recently moved several of my domains to GoDaddy, and am currently struggling to get the directory structure properly set up with each of them. 我最近将我的几个域移到了GoDaddy,目前正在努力使每个域都正确设置目录结构。 I have each of my addon domains in its own directory under public_html/. 我的每个插件域都位于public_html /下的自己的目录中。 Additionally, I want to move my primary domain into its own subfolder for cleanliness. 另外,我想将主域移到其自己的子文件夹中以保持整洁。 As a result, my directory setup looks like this: 结果,我的目录设置如下所示:

public_html/
    primarydomain/
    addondomainA/
    addondomainB/
    addondomainC/

I setup my .htaccess file under public_html as follows: 我在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]

The addon domain redirects work perfectly, and if I try to access primarydomain.com, the request is properly rewritten to the primarydomain/ subdirectory. 插件域重定向可以正常工作,并且如果我尝试访问primarydomain.com,请求将被正确地重写到primarydomain /子目录中。 However, if I try to access primarydomain.com/primarydomain, nothing gets rewritten (as far as I can tell) and the user can directly access the page. 但是,如果我尝试访问primarydomain.com/primarydomain,则不会重写任何内容(据我所知),并且用户可以直接访问该页面。 I would like to disallow all direct access requests for the primarydomain/ folder, but nothing I try seems to work. 我想禁止对primarydomain /文件夹的所有直接访问请求,但是我尝试的任何方法似乎都没有效果。 I thought that removing: 我以为删除:

RewriteCond %{REQUEST_URI} !^/primarydomain/

Would do something, but it seems to have no effect on the behavior. 会做一些事情,但似乎对行为没有影响。 Similarly, both: 同样,两者:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

...seem to have no effect if deleted. ...似乎被删除无效。 I even tried adding a fourth RedirectMatch clause up top, hoping to catch the folder name if it's inserted, but it leads to a redirect loop, as if it's processing the commands out of order. 我什至尝试在顶部添加第四个RedirectMatch子句,希望能够在插入文件夹名称时捕获它的名称,但这会导致重定向循环,就好像它在无序地处理命令一样。 I've devoured all the answers I could find on stack overflow, but none of them solve the issue. 我已经吞噬了在堆栈溢出时可以找到的所有答案,但是没有一个可以解决问题。 I've tried multiple fresh browsers, and am pretty certain that this is not a cache problem. 我已经尝试了多个全新的浏览器,并且可以肯定这不是缓存问题。

Does anybody have any ideas how to accomplish this seemingly super-basic task? 是否有人有想法完成这项看似超基本的任务? Is there something I've overlooked? 有什么我忽略的东西吗? Thanks in advance. 提前致谢。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM