.htaccess cPanel-.hts子域的访问点

.htaccess cPanel-.hts子域的访问点,.htaccess,zend-framework2,subdomain,cpanel,document-root,.htaccess,Zend Framework2,Subdomain,Cpanel,Document Root,我有两个域名指向同一主机 域名a.com和域名b.com domain_b.com实际上是指向domain_a.com的子域(即domain_b.domain_a.com) 目录结构 public_html | |---- domain_a |---- domain_b |---- ... |---- .htaccess .htaccess的内容是 AddHandler application/x-httpd-php54 .php RewriteEngine on RewriteC

我有两个域名指向同一主机

域名a.com域名b.com

domain_b.com实际上是指向domain_a.com的子域(即domain_b.domain_a.com)

目录结构

public_html
 |
 |---- domain_a
 |---- domain_b
 |---- ...
 |---- .htaccess
.htaccess
的内容是

AddHandler application/x-httpd-php54 .php

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?domain_a.com$
RewriteCond %{REQUEST_URI} !^/domain_a/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /domain_a/$1
RewriteCond %{HTTP_HOST} ^(www.)?domain_a.com$
RewriteRule ^(/)?$ domain_a/index.html [L] 
然而,我的域_b.com实际上正在使用ZendFramework 2。文档根位于
public
dir

i、 e

这导致错误
请求超出了10个内部重定向的限制,原因可能是配置错误。如有必要,使用“LimitInternalRecursion”增加限制。使用“日志级别调试”获取回溯跟踪。

域/public
中还有一个
.htaccess
文件。这是默认的

试试这些规则:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]

RewriteCond %{HTTP_HOST} ^(www.)?domain_a\.com$
RewriteRule !^domain_a(/|$) /domain_a%{REQUEST_URI} [L,NC]

RewriteCond %{HTTP_HOST} ^(www.)?domain_b\.com$
RewriteRule !^domain_b/public/index\.php(/|$) /domain_b/public/index.php [L,NC]

通过在创建子域期间将子域的路径设置为
domain\u b/public/
,可以解决此问题


问题是什么?显示两个域的
VirtualHost
条目。这是共享主机,我想我无法更改虚拟主机。基本上我想要我的
domain_b.com
指向
public\u html/domain\u b/public
我不想让你改变我只想看看那些条目来了解你的设置。好了,在下面发布了一个答案。现在我收到500个内部服务器错误。我找不到vhost配置文件。你能检查一下你的Apache error.log吗?原因是这个500
[alert][client xxx.xxx.xxx.xxx]/home/user/public\u html/.htaccess:RewriteCond:bad flag delimiters
,这意味着你在复制/粘贴这个答案时输入了一些错误。如果您在上面看到,我甚至没有在
RewriteCond
中使用任何标志。您需要确保.htaccess.Ya的
RewriteCond
行中没有多余的空格,您是对的。现在,由于可能的配置错误,我发现这个
请求超过了10个内部重定向的限制。如有必要,使用“LimitInternalRecursion”增加限制。使用“日志级别调试”获取回溯跟踪。
# Use PHP5.4 as default
AddHandler application/x-httpd-php54 .php

RewriteEngine on

RewriteCond %{HTTP_HOST} ^(www.)?domain_a\.com$
RewriteRule !^domain_a(/|$) /domain_a%{REQUEST_URI} [L,NC]

RewriteCond %{HTTP_HOST} ^(www.)?domain_b\.com$
RewriteRule !^domain_b/public(/|$) /domain_b/public%{REQUEST_URI} [L,NC]
RewriteEngine On
# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# The following rewrites all other queries to index.php. The 
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting, the base path will be prepended to 
# allow proper resolution of the index.php file; it will work
# in non-aliased environments as well, providing a safe, one-size 
# fits all solution.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]

RewriteCond %{HTTP_HOST} ^(www.)?domain_a\.com$
RewriteRule !^domain_a(/|$) /domain_a%{REQUEST_URI} [L,NC]

RewriteCond %{HTTP_HOST} ^(www.)?domain_b\.com$
RewriteRule !^domain_b/public/index\.php(/|$) /domain_b/public/index.php [L,NC]