当我在第二个域中尝试获取第一个域的第一组RewriteRule时,它将无法成功跳过3个RewriteRule,我将得到500个内部服务器错误,这很可能是htaccess。我可以毫无问题地进入第一个域,但我希望这两个域可以分别到达各自的路径。
# First Domain - Ex: foo.bar.firstDomain.com/content/video/1
RewriteCond %{HTTP_HOST} (.[^\.]+)(.+)(firstDomain)(\..+) [NC]
RewriteCond %{HTTP_HOST} !(.[^\.]+)\.(.[^\.]+)\.(secondDomain)(\..+) [NC,S=3]
RewriteRule ^/?$ /template/firstDomain/home.php [NC,L,QSA]
RewriteRule ^(content)/(photo|video)/([^\/]+)$ /$1/$2/$3/ [NC,L,R=301,QSA]
RewriteRule ^(content)/(photo|video)/([^\/]+) /template/firstDomain/landing.php?p_sContentType=$2&p_nContentId=$3 [NC,L,QSA]
# Second Domain - Ex: foo.bar.secondDomain.com/content/video/1
RewriteCond %{HTTP_HOST} (.[^\.]+)\.(.[^\.]+)\.(secondDomain)(\..+) [NC]
RewriteRule ^/?$ /template/secondDomain/home.php [NC,L,QSA]
RewriteRule ^(content)/(photo|video)/([^\/]+)$ /$1/$2/$3/ [NC,L,R=301,QSA]
RewriteRule ^(content)/(photo|video)/([^\/]+) /template/secondDomain/landing.php?p_sContentType=$2&p_nContentId=$3 [NC,L,QSA]
更新:我已将htaccess文件的第二行从RewriteCond更新为RewriteRule,试图跳到第二个域RewriteCond和RewriteRule。仍然没有得到想要的结果。
# First Domain - Ex: foo.bar.firstDomain.com/content/video/1
RewriteCond %{HTTP_HOST} (.[^\.]+)(.+)(firstDomain)(\..+) [NC]
RewriteRule !^foo\.bar\.(secondDomain)(\..+) [NC,S=3]
RewriteRule ^/?$ /template/firstDomain/home.php [NC,L,QSA]
RewriteRule ^(content)/(photo|video)/([^\/]+)$ /$1/$2/$3/ [NC,L,R=301,QSA]
RewriteRule ^(content)/(photo|video)/([^\/]+) /template/firstDomain/landing.php?p_sContentType=$2&p_nContentId=$3 [NC,L,QSA]
# Second Domain - Ex: foo.bar.secondDomain.com/content/video/1
RewriteCond %{HTTP_HOST} (.[^\.]+)\.(.[^\.]+)\.(secondDomain)(\..+) [NC]
RewriteRule ^/?$ /template/secondDomain/home.php [NC,L,QSA]
RewriteRule ^(content)/(photo|video)/([^\/]+)$ /$1/$2/$3/ [NC,L,R=301,QSA]
RewriteRule ^(content)/(photo|video)/([^\/]+) /template/secondDomain/landing.php?p_sContentType=$2&p_nContentId=$3 [NC,L,QSA]