问题原文
原帖链接 · Tom Monks · CC BY-SA 3.0
I’m setting up a Wordpress website with a new domain name to replace my client’s current website. I’d like to redirect the old domain to the new domain in a way that will maintain the search engine rankings of the old site if at all possible. Once the new site is ready, my plan is to have the old domain name moved to a parked domain on the new server, and then use 301 redirects to redirect requests for the old domain name and html pages to the corresponding Wordpress pages on the new domain. So, as an example, a request for http://www.olddomain.ca/success-stories.html would be redirected to https://newdomain.com/testimonials/.
I’ve tested the redirects for each html page on the new server and it seems to work correctly, but I’m not sure how to test redirection of the old domain name until it’s actually set up as a parked domain pointing to the new server.
So I have two questions:
- Will this approach maintain the search engine ranking of the old site, or is there a better way?
Will these rules redirect the parked domain to the new domain (in addition to removing www)?
RewriteCond %{HTTP_HOST} !^newdomain\.com [NC] RewriteRule ^(.*)$ https://newdomain.com/$1 [R,L]
I’m using 302 redirects for now, but will switch to 301's once I’m done testing. This is my first time working with the htaccess file, so I welcome any other suggestions on how to improve it.
# Redirect HTML pages from old site to new equivalents
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html?$ / [NC,R,L]
RewriteRule ^about-us\.html?$ /about/ [NC,R,L]
RewriteRule ^coaching\.html?$ /services/ [NC,R,L]
RewriteRule ^how-we-do-it\.html?$ /services/ [NC,R,L]
RewriteRule ^news-calendar\.html?$ / [NC,R,L]
RewriteRule ^philosophy\.html?$ /about/ [NC,R,L]
RewriteRule ^services\.html?$ /services/ [NC,R,L]
RewriteRule ^success-stories\.html?$ /testimonials/ [NC,R,L]
RewriteRule ^teams\.html?$ /services/ [NC,R,L]
RewriteRule ^training\.html?$ /services/ [NC,R,L]
# Remove WWW Prefix, enforce HTTPS, and redirect parked domain
RewriteEngine On
RewriteCond %{SERVER_PORT} 80 [OR]
RewriteCond %{HTTP_HOST} !^newdomain\.com [NC]
RewriteRule ^(.*)$ https://newdomain.com/$1 [R,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
已采纳解答
原帖链接 · Raul Reyes · CC BY-SA 3.0
1) By applying 301 redirects you will basically tell search engines that you have moved that page or group of pages to another location permanently. No problems here, all good.
Google has declared several times that 301 won’t have an impact in transferring the ranking power from those links pointing to your old URLs. So to answer your first question, rest assured you won’t loose any rankings that way.
However, you might loose ranking from potentially more than 200 other ranking factors that will have to be reassessed once you have the new website live. You might loose rankings for changing the layout, website structure and design, having new content, etc. You might also loose ranking even by changing servers, the website will have a different location to serve content from, impact in performance will also be playing an important part.
What is expected before someone decides to migrate, upgrade or improve any website, is that we know our customers needs or we have learned from our past experiences enough that any chance we do will have a positive impact in the business or most importantly to our user base. But unfortunately that is not always the case.
2) the htaccess code looks good, but don’t take my word, you need to test it because each environment is different. Make sure that when you are trying to redirect any URL, specially the homepage, you don’t do more than one redirect.
So for example, if you are redirecting example-old.com to example-new.com make sure you don’t redirect first to www.example-old.com and then to example-new.com.
Make tests so you can be sure that either www. Or non www. version of the website will redirect always to example-new.com
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
