htaccess redirects from old site to new site
There is an existing site h*tp://www.oldsite.com/ which I need to redirect to the new site h*tp://www.newsite.co.za/. The oldsite is already setup as parked domain on the newsite host account. Below are the file structure of the newsite host. h*tp://www.newsite.co.za/ - /public_html h*tp://www.oldsite.com/ - /public_html/oldsite.com
The newsite is a complete restructure of the oldsite, so I needed to redirect all indexed pages of the oldsite to some corresponding pages of the newsite. I have managed to redirect the static pages but Im having a hard time on the dynamic pages. For example:
h*tp://www.oldsite.com/The_Wine_Shop/Bales_Private_Vintners.aspx?CatID=13&PageID=175&RefPageID=169
to
h*tp://www.newsite.co.za/buy-wine/buy-wine-online/
There are several pages that needs to be redirected based on the example format above. What will be the easiest way to do the redirects. I'm thinking to just redirect all the files inside the "The_Wine_Shop" folder including the dynamic pages but I dont have any idea how to do that in this format.
By the way h开发者_如何学JAVAere is the code for my oldsite to newsite index page redirect.
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]
You could add another ruleset to your .htaccess:
RewriteCond %{REQUEST_URI} ^/The_Wine_Shop/
RewriteRule ^(.*)$ http://www.newsite.co.za/buy-wine/buy-wine-online/ [R=301,L]
This would redirect every page beginning with /The_Wine_Shop/
.
If you want to check the requested URI and the querystring you can go with something like this:
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]
If you don't care if the URL is written upper or lowercase add the NC-Flag to the conditions.
You should also add the <link rel="canonical" href="http://new-and-correct-url" />
tag to your new sites <head>
.
More info on rel canonical.
精彩评论