我想将旧域名的子域名重定向到新域名上的目录。
例如 forum.old-domain.com 应该重定向到 new-domain.com/forum 从 old-domain.com 到 www.new-domain.com 的重定向正常,但子域名除外。
htaccess 看起来像这样:
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^forum\.old-domain\.de [nc]
rewriterule ^(.*)$ http://www.new-domain.de/forum/$1 [r=301,nc,l]
rewritecond %{http_host} !^www.new-domain.de [nc]
rewriterule ^(.*)$ http://www.new-domain.de/$1 [r=301,nc,l]
# rewritecond %{http_host} ^forum.old-domain.de [nc]
# rewriterule ^(.*)$ http://www.new-domain.de/forum/$1 [r=301,nc,l]
rewritecond %{http_host} ^old-domain.de [nc]
rewriterule ^(.*)$ http://www.new-domain.de/$1 [r=301,nc,l]
rewritecond %{http_host} ^www.old-domain.de [nc]
rewriterule ^(.*)$ http://www.new-domain.de/$1 [r=301,nc,l]
问题是 forum.old-domain.com 重定向到 www.new-domain.com,但我希望它重定向到 www.new-domain.com/forum。有什么建议吗?我遗漏了什么?
提前致谢!
编辑:
添加虚拟主机条目:
maindomain new-domain.com 配置:
<VirtualHost *:80>
ServerName new-domain.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/www/new-domain.com/htdocs
ServerAlias www.new-domain.com
</VirtualHost>
maindomain old-domain.com 配置:
<VirtualHost *:80>
ServerName old-domain.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/www/new-domain.com/htdocs
ServerAlias www.old-domain.com
</VirtualHost>
子域名 old-domain.com 配置:
<VirtualHost *:80>
ServerName forum.old-domain.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/www/new-domain.com/htdocs/forum
ServerAlias forum.old-domain.com
</VirtualHost>