wordpress跳轉go頁面 wordpress跳轉https
Jollychic時尚達人WordPress2025-04-248140
要在WordPress中跳轉到Go頁面,你可以使用以下代碼:
<?php
// 獲取當前頁面的URL
$current_url = $_SERVER['REQUEST_URI'];
// 檢查是否為主頁
if ($current_url == 'index.php') {
// 是主頁,跳轉到Go頁面
$go_page = 'https://www.example.com/go'; // 替換為你的Go頁面URL
header('Location: ' . $go_page);
} else {
// 如果不是主頁,跳轉到其他頁面
$other_pages = array(
'about',
'contact',
'privacy-policy',
'terms-of-service'
);
if (in_array($current_url, $other_pages)) {
$go_page = 'https://www.example.com/go'; // 替換為你的Go頁面URL
header('Location: ' . $go_page);
} else {
// 如果不是主頁或目標頁面,返回404錯誤
http_response_code(404);
die('Not Found');
}
}
?>
將上述代碼添加到你的WordPress主題的functions.php
文件中,或者在需要跳轉的地方添加以下代碼:
<?php
// 獲取當前頁面的URL
$current_url = $_SERVER['REQUEST_URI'];
// 檢查是否為主頁
if ($current_url == 'index.php') {
// 是主頁,跳轉到Go頁面
$go_page = 'https://www.example.com/go'; // 替換為你的Go頁面URL
header('Location: ' . $go_page);
} else {
// 如果不是主頁,跳轉到其他頁面
$other_pages = array(
'about',
'contact',
'privacy-policy',
'terms-of-service'
);
if (in_array($current_url, $other_pages)) {
$go_page = 'https://www.example.com/go'; // 替換為你的Go頁面URL
header('Location: ' . $go_page);
} else {
// 如果不是主頁或目標頁面,返回404錯誤
http_response_code(404);
die('Not Found');
}
}
?>
本文內容根據(jù)網(wǎng)絡資料整理,出于傳遞更多信息之目的,不代表金鑰匙跨境贊同其觀點和立場。
轉載請注明,如有侵權,聯(lián)系刪除。