이사 약 100 사에서 오래 된 웹사이트에 새로운 하나입니다. 를 만들고 싶은데로 리디렉션에서 옛 사이트 헤더는 경우,그래서 그 이전 URL 을 문서의 될 것이 많이 방문한 방문자가할 수 있어 새로운 URL 을 문서.
그러나,그냥 바꾸는 도메인을 하지 않을 것은 속으로 변경 permalink 의하십시오. 그래서 난 것이요"데이터베이스"(배열?) 는 것을 결정하는 경우는 실제 URL 로 리디렉션 데이터베이스에서,다음과 같:
// "the old permalink" = "the new permalink"
$urlpermalink["article-cars"] = "http://NewWebsite.com/new-cars-article";
$urlpermalink["an-article-dogs"] = "http://NewWebsite.com/new-dogs-text";
$urlpermalink["old-text-trees"] = "http://NewWebsite.com/new-blogcontent-about-trees";
그래서 예를 들어 경우 방문자가 방문"http://OldWebsite.com/article-cars"그는 리디렉션해야"http://NewWebsite.com/new-cars-article"때문에,어떻게 데이터베이스/배열을 말한다.
그래서 나는 수가 다음과 같다:
$visitingurl = $_SERVER[REQUEST_URI]; // Getting the URL the visitor is on now
foreach( $urlpermalink as $value ) { // For every entry in the database/array...
if (strpos($visitingurl, $urlpermalink) !== false) { // check if the visitingurl contains that (like "article-cars")
// The visitor is indeed on an old URL which is in the database/array, so let's redirect him to the new URL
header("HTTP/1.1 301 Moved Permanently");
header(url . $_SERVER['QUERY_STRING']);
exit();
}
}
물론 이 코드는 완전히 잘못된 것,그러나 나는 거의 없습에 대한 아이디어 PHP,그래서 당신은 도울 수 있습니다 나 이? (a JavaScript솔루션은 너무 잘,또는 htaccess,또는 어떤:))
대단히 감사합니다!