簡體   English   中英

如何將wp-admin重定向到另一個URL

[英]How can I redirect wp-admin to another url

如何將用戶從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

自我解釋。 從第一個鏈接/wp-admin Redirect到第二個鏈接http://www.example.com/custom

另一種方法可能是使用wordpress wp_redirect()函數,如下所示:

wp_redirect('http://example.com/custom', $status );

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');

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM