301 Redirect from Wix to WordPress

人盡茶涼 提交于 2019-12-02 10:52:55

问题


A company I'm working for had a WIX based site. I recreated the site on WordPress moved the hosting and redirected the domain. I then attempted to do the page redirects to the new URLs on the WordPress site with the standard .httaccess file 301 redirects.

Redirect 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.

How can I execute my 301 redirects and retain my previous page rank?


回答1:


i managed to redirect from wix to wordpress by adding this code (by Themee) to the functions.php on my theme directory.

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. i think the next code (in the .htaccess file) should help SEO, but still need some modification that i dont know about. this was an help by "barryhunter" from Google Forum.

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

its will be nice if someone can determine what exactly should be written in the .htacess file.




回答2:


I had the same situation. The only solution I found is to create redirect.js file with the following content:

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. This should do the trick.




回答3:


Since wix URLs are hashtags, they cannot be redirected via .htaccess. You must use javascript to redirect urls, e.g.:

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]);
}


来源:https://stackoverflow.com/questions/21608542/301-redirect-from-wix-to-wordpress

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!