Apache 从子文件夹运行网站

Apache 从子文件夹运行网站,apache,.htaccess,mod-rewrite,url-rewriting,Apache,.htaccess,Mod Rewrite,Url Rewriting,我有几个网站使用共享主机托管。“主域”位于/public\u html目录中。我要做的是从/public\u html/domain.com运行它。这是我的/public\u html/.htaccess文件: RewriteEngine on RewriteCond %{HTTP_HOST} ^(www.)?domain.com$ RewriteCond %{REQUEST_URI} !^/domain.com/ RewriteCond %{REQUEST_FILENAME} !-f Rewr

我有几个网站使用共享主机托管。“主域”位于
/public\u html
目录中。我要做的是从
/public\u html/domain.com
运行它。这是我的
/public\u html/.htaccess
文件:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteCond %{REQUEST_URI} !^/domain.com/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /domain.com/$1

RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteRule ^(/)?$ domain.com/index.html [L]
一般来说,这很有效,除非我尝试访问目录,比如
http://www.domain.com/test
,由此我被重定向到
http://www.domain.com/domain.com/test
。为了澄清,不应该有重定向,服务器应该只从指定的子目录为站点提供服务

任何帮助都将不胜感激。

请使用


谢谢你的回复。这是我尝试将规则与RewriteBase一起使用时遇到的错误:
在此服务器上找不到请求的URL/[site folder name]/[site folder name]/index.html。
。请记住,
.htaccess
位于
/public\u html
中。
RewriteEngine on
RewriteBase /domain.com/
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteCond %{REQUEST_URI} !^/domain.com/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /domain.com/$1

RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteRule ^(/)?$ domain.com/index.html [L]