正在将子域重定向到具有.htaccess的子文件夹

正在将子域重定向到具有.htaccess的子文件夹,.htaccess,redirect,subdomain,mod-rewrite,.htaccess,Redirect,Subdomain,Mod Rewrite,我正在尝试将子域重定向到子文件夹 我有3个子域指向根目录(/test)上名为“test”的文件夹 subdomain1.mysite.com subdomain2.mysite.com subdomain3.mysite.com 在测试中,我有3个文件夹`/test/subdomain1、/test/subdomain2、/test/subdomain3` 我想要的是: 当我转到subdomain1.mysite.com时,它应该是从:/test/subdomain1读取的 当我转到subdom

我正在尝试将子域重定向到子文件夹 我有3个子域指向根目录(/test)上名为“test”的文件夹

subdomain1.mysite.com
subdomain2.mysite.com
subdomain3.mysite.com
在测试中,我有3个文件夹`/test/subdomain1、/test/subdomain2、/test/subdomain3`
我想要的是:
当我转到subdomain1.mysite.com时,它应该是从:/test/subdomain1读取的
当我转到subdomain2.mysite.com时,它应该是从:/test/subdomain2读取的
当我转到subdomain3.mysite.com时,它应该是从:/test/subdomain3读取的
这是我的htaccess used-放在文件夹“/test”中,我想问题出在这里!!:
选项-索引
重新启动发动机
重写基/
RewriteCond%{HTTP_HOST}^subdomain1.mysite.com$[NC]
重写规则^(.*)$subdomain1/$1[L,QSA]
RewriteCond%{HTTP_HOST}^subdomain2.mysite.com$[NC]
重写规则^(.*)$subdomain2/$1[L,QSA]
RewriteCond%{HTTP_HOST}^subdomain2.mysite.com$[NC]
重写规则^(.*)$subdomain3/$1[L,QSA]
当访问任何子域时,我收到“500内部服务器错误”。。。
RewriteBase在子文件夹中有效吗?如果不放根?
有什么想法吗?
谢谢

我认为500错误是因为您没有在URL中跳过您的

RewriteCond %{HTTP_HOST} ^subdomain1.mysite.com$ [NC]
应该是

RewriteCond %{HTTP_HOST} ^subdomain1\.mysite\.com$ [NC]
有一个错误

RewriteBase /
RewriteCond %{HTTP_HOST} ^subdomain1.mysite.com$ [NC]
RewriteRule ^(.*)$ subdomain1/$1 [L,QSA]
RewriteCond %{HTTP_HOST} ^subdomain2.mysite.com$ [NC]
RewriteRule ^(.*)$ subdomain2/$1 [L,QSA]
RewriteCond %{HTTP_HOST} ^subdomain2.mysite.com$ [NC]
RewriteRule ^(.*)$ subdomain3/$1 [L,QSA]
最后两行:

RewriteCond %{HTTP_HOST} ^subdomain2.mysite.com$ [NC]
RewriteRule ^(.*)$ subdomain3/$1 [L,QSA]

subdomain2而不是subdomain3

这一行的

是一个错误吗
RewriteRule^(.*)$subdomain2/$1[L,QSA]
还是你的htaccess文件中的错误?啊,不,是拼写错误,我把它删除了!!谢谢马特的帮助!!我试图逃避这些点,但仍然有同样的错误!!我的域包含“-”这意味着什么吗?htaccess放在文件夹“test”中我是否将其放在根级别并更改重写基础?将htaccess移到根级别,并尝试转义连字符。我通过在选项+FollowSymLinks RewriteRule ^google\.html上添加
RewriteEngine来确保模式重写工作正常http://www.google.com/? [R=301,L]
嘿,马特!就像你说的那样!!!但是如果我在文件夹subdomain1,subdomain2,subdomain3中有一个index.php文件就好了!!但在subdomain2中,我得到一个500内部服务器错误,因为我没有索引,我将有一个包含图像的文件夹列表。。。
RewriteCond %{HTTP_HOST} ^subdomain2.mysite.com$ [NC]
RewriteRule ^(.*)$ subdomain3/$1 [L,QSA]