We were previously using a non-search engine friendly custom CMS for our case record systems. We are planning to migrate to WordPress. As we have several links pointing to our previous install we want to keep them live in a new domain.
Fortunately, all our links in the previous CMS were in the format http://www.example.com/cases/the-case-number.
We are now thinking of how to implement it. I think we have two solutions:
-
Either put a
redirect_to_old()function at top of our WordPress header to get the current URL on each page load and if the URL request matches “/cases/” then redirect to the previous CMS usingheader("Location: $URL");. This is implemented now.function redirect_to_old(){ $requestUrl = $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; if (stripos($requestUrl, "/cases/")!== false){ $URLpart = explode("/cases/",$requestUrl); $newURL = "http://sub.xyz.com/cases/".$URLpart[1]; header("Location: $newURL"); /* Redirect browser */ exit; }else{ return true; } } -
To use some .htaccess code and do the redirect. But I am not an expert with .htaccess.
Do I have to add a 301 error before the redirect? And are there any bad consequences in terms of SEO if we do a redirect like this? The major purpose of this migration is SEO.
Use 301 redirect via .htaccess (You needn’t even try to search index.php if You know, that URL is old, yeah?). Here’s some example, I hope it will be useful for You
Yes. Search Engine must know, that this redirect is permanent
Nope, that’s ok.