htaccess重定向子域和文件夹文件

时间:2012-10-22 13:07:16

标签: apache .htaccess

所以我们开发了一个开发网站,例如:test.domain.com/dev/filename.html,它被Google索引,所以我需要将它们重定向到www.newdomain.com/filename.html而不仅仅是文件还有文件夹/文件,如。

test.domain.com/dev/example/filename.html

或 www.newdomain.com/example/example/filename.html

www.newdomain.com/filename.html

请注意,测试域上的/ dev /文件夹无法在重定向上推送?

有人对此有任何想法吗?

我试过了:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !test.domain.co.uk/dev/$ [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]

经过一些测试,重定向到http://www.newdomain.com/dev/page.html,我需要删除/ dev / .....

以及其他一些选择,同时狩猎但没有达到要求。

提前致谢

1 个答案:

答案 0 :(得分:1)

你还需要RewriteCond,所以试试:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^test.domain.com [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]
相关问题