2011-10-03 104 views
2

有一个现有的网站H * TP重定向/。旧网站已被设置为新网站主机帐户上的停放网域。以下是newsite主机的文件结构。 H * TP://www.newsite.co.za/ - /的public_html H * TP://www.oldsite.com/ - /public_html/oldsite.comhtaccess的从旧网站到新网站

的newsite是的一个完整的重组oldsite,所以我需要的oldsite的所有索引的网页重定向到newsite的一些相应的页面。我设法重定向静态页面,但Im在动态页面上很难。例如:

h*tp://www.oldsite.com/The_Wine_Shop/Bales_Private_Vintners.aspx?CatID=13&PageID=175&RefPageID=169 

h*tp://www.newsite.co.za/buy-wine/buy-wine-online/ 

有迹象表明,需要根据上面的例子格式被重定向几页。什么是最简单的重定向方式。我想刚才的所有文件重定向包括动态页的“The_Wine_Shop”文件夹中,但我没有任何想法如何做,在这种格式。

通过这里的方法是我oldsite到newsite索引页面重定向代码。

Options +FollowSymLinks 
RewriteEngine On 
RewriteCond %{HTTP_HOST} ^oldsite\.com [OR] 
RewriteCond %{HTTP_HOST} ^www.oldsite\.com 
RewriteRule ^/?(.*) http://www\.newsite\.co\.za/$1 [R=permanent,L] 

回答

1

您可以添加另一个规则集来你的.htaccess:

RewriteCond %{REQUEST_URI} ^/The_Wine_Shop/ 
RewriteRule ^(.*)$ http://www.newsite.co.za/buy-wine/buy-wine-online/ [R=301,L] 

这将每一个页面重定向与/The_Wine_Shop/开始。

如果你想检查请求的URI,你可以像这样的东西去查询字符串:

RewriteCond %{REQUEST_URI} ^/The_Wine_Shop/Bales_Private_Vintners\.aspx$ 
RewriteCond %{QUERY_STRING} CatID=13 
RewriteCond %{QUERY_STRING} PageID=175 
RewriteCond %{QUERY_STRING} RefPageID=169 
RewriteRule ^(.*)$ http://www.newsite.co.za/buy-wine/buy-wine-online/ [R=301,L] 

如果你不介意的URL被写入大写或小写的添加NC-Flag的条件。

你也应该在<link rel="canonical" href="http://new-and-correct-url" />标记添加到您的新网站<head>

Moreinfo上相对规范。

相关问题