如何将用户从wp-admin
重定向到另一个自定义页面,例如我想重定向此网址:
http://example.com/wp-admin
为:
http://example.com/custom
答案 0 :(得分:1)
wp_redirect( $location, $status );
exit;
或尝试这样
wp_redirect( home_url( '/custom/' ) );
exit();
答案 1 :(得分:1)
最简单的方法可能是在.htaccess
中创建webroot directory
文件。
然后将其写入其中:
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 );
答案 2 :(得分:1)
在 functions.php 文件中使用以下代码重定向到其他网址。
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');