我如何可以重定向用戶從wp-admin
到另一個自定義頁面,比如我想重定向這個網址:我如何可以重定向可溼性粉劑管理員到另一個URL
http://example.com/wp-admin
到:
http://example.com/custom
我如何可以重定向用戶從wp-admin
到另一個自定義頁面,比如我想重定向這個網址:我如何可以重定向可溼性粉劑管理員到另一個URL
http://example.com/wp-admin
到:
http://example.com/custom
wp_redirect($location, $status);
exit;
或嘗試這樣
wp_redirect(home_url('/custom/'));
exit();
最簡單的方法可能是在您的webroot directory
中創建一個.htaccess
文件。
後來寫了進去:
Redirect /wp-admin http://www.example.com/custom
相當自我解釋。 Redirect
從第一鏈接/wp-admin
到第二鏈路http://www.example.com/custom
另一種方法很可能是使用WordPress wp_redirect()
功能,這樣的事情:
wp_redirect('http://example.com/custom', $status);
我應該在哪裏放置'wp_redirect('http://example.com/custom',$ status);'? – Resolution 2014-10-01 10:35:32
@ wp-login.php內的分辨率 – Xatenev 2014-10-01 11:01:47
使用下面你的functions.php文件重定向到另一個代碼URL。
function redirect_login_page(){
// Store for checking if this page equals wp-login.php
$page_viewed = basename($_SERVER['REQUEST_URI']);
// Where we want them to go
$login_page = http://example.com/custom; //Write your site URL here.
// Two things happen here, we make sure we are on the login page
// and we also make sure that the request isn't coming from a form
// this ensures that our scripts & users can still log in and out.
if($page_viewed == "wp-login.php" && $_SERVER['REQUEST_METHOD'] == 'GET') {
// And away they go...
wp_redirect($login_page);
exit();
}
}
add_action('init','redirect_login_page');
我應該在哪裏放置這段代碼? – Resolution 2014-10-01 10:32:07
答覆編輯.. – 2014-10-01 10:40:56
我應該在哪裏放置這段代碼? – Resolution 2014-10-01 10:32:23