[英]301 Redirect from Wix to WordPress
A company I'm working for had a WIX based site. 我正在工作的一家公司拥有一个基于WIX的网站。 I recreated the site on WordPress moved the hosting and redirected the domain.
我在WordPress上重新创建了该站点,从而移动了主机并重定向了域。 I then attempted to do the page redirects to the new URLs on the WordPress site with the standard .httaccess file 301 redirects.
然后,我尝试使用标准的.httaccess文件301重定向将页面重定向到WordPress网站上的新URL。
Redirect 301 /#!product/prd1/1063533171/42%22-workstation-(mc-42) http://www.mydomain.com/product/workstation/ 重定向301 /#!product / prd1 / 1063533171/42%22-workstation-(mc-42) http://www.mydomain.com/product/workstation/
I have now found that WIX uses a hashbang (#!) in the url link structure. 我现在发现WIX在URL链接结构中使用了hashbang(#!)。
How can I execute my 301 redirects and retain my previous page rank? 如何执行301重定向并保留以前的页面排名?
i managed to redirect from wix to wordpress by adding this code (by Themee) to the functions.php on my theme directory. 通过将此代码(由Themee添加)到主题目录上的functions.php中,我设法从wix重定向到wordpress。
function themee_hash_redirects() {
?>
<script type="text/javascript">
function themee_hashtag_redirect( hashtag, url) {
var locationHash = document.location.hash;
if ( locationHash.match(/#!/img) ) {
if ( hashtag == locationHash ) {
document.location.href = url;
}
}
}
// Examples how to use themee_hashtag_redirect
themee_hashtag_redirect('#!dvd-content/c1yws', '/dvd-content/');
themee_hashtag_redirect('#!krav-maga-shirts/c9r5', '/krav-maga-shirts/');
</script>
<?php
}
add_action('wp_footer', 'themee_hash_redirects');
as i understood, this only help to redirect your visitors to the correct URL, but not help to SEO. 据我了解,这仅有助于将访问者重定向到正确的URL,而无助于SEO。 i think the next code (in the .htaccess file) should help SEO, but still need some modification that i dont know about.
我认为下一个代码(在.htaccess文件中)应该可以帮助SEO,但仍然需要一些我不知道的修改。 this was an help by "barryhunter" from Google Forum.
这是Google论坛中“ barryhunter”的帮助。
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=krav-maga-shirts/c9r5
RewriteRule ^$ http://www.972kravmaga.com/krav-maga-shirts [QSA,L]
its an example of one page redirect. 它是一页重定向的示例。 the person who helped me said can check if its working on this page: http://www.rexswain.com
帮助我的人说可以检查其是否在此页面上正常工作: http : //www.rexswain.com
its will be nice if someone can determine what exactly should be written in the .htacess file. 如果有人可以确定应在.htacess文件中确切写入什么内容,它会很好。
I had the same situation. 我有同样的情况。 The only solution I found is to create redirect.js file with the following content:
我发现的唯一解决方案是创建具有以下内容的redirect.js文件:
var hashesarr = { "#!about-us/c1it7":'/about-us/',
"#!patio-covers/ce54":'/patio-covers/',
"#!lattice/c1mz":'/patio-covers/lattice/' };
for (var hash in hashesarr) {
var patt = new RegExp(hash);
if (window.location.hash.match(patt) !== null) {
window.location.href = hashesarr[hash];
}
}
Then you should upload this file to your server and include it between <head></head>
tags. 然后,您应该将此文件上传到服务器,并将其包含在
<head></head>
标记之间。 This should do the trick. 这应该可以解决问题。
Since wix URLs are hashtags, they cannot be redirected via .htaccess. 由于wix URL是标签,因此无法通过.htaccess重定向。 You must use javascript to redirect urls, eg:
您必须使用javascript重定向网址,例如:
var redirects = {
'#!about/c10fk':'about',
'#!contact/c10fk':'contact',
'#!help/c10fk':'help'
};
if(window.location.hash != '' && redirects.hasOwnProperty(window.location.hash)) {
window.location.replace(redirects[window.location.hash]);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.