Reference › Functions wp_redirect_admin_locations ()
Since 3.4.0
Source wp-includes/canonical.php:1038Description Uses Source History Redirects a variety of shorthand URLs to the admin.
Description If a user visits example.com/admin, they'll be redirected to /wp-admin.Visiting /login redirects to /wp-login.php, and so on.
Uses · 7 is_404() Determines whether the query has resulted in a 404 (returns no results). home_url() Retrieves the URL for the current site where the front end is accessible. site_url() Retrieves the URL for the current site where WordPress application files (e.g. wp-blog-header.php or the wp-admin/ folder) are accessible. untrailingslashit() Removes trailing forward slashes and backslashes if they exist. wp_redirect() Redirects to another page. admin_url() Retrieves the URL to the admin area for the current site. wp_login_url() Retrieves the login URL. Source View on Trac ↗ View on GitHub ↗
1038 function wp_redirect_admin_locations ( ) { 1039 global $wp_rewrite ; 1040 1041 if ( ! ( is_404 ( ) && $wp_rewrite -> using_permalinks ( ) ) ) { 1042 return ; 1043 } 1044 1045 $admins = array ( 1046 home_url ( 'wp-admin' , 'relative' ) , 1047 home_url ( 'dashboard' , 'relative' ) , 1048 home_url ( 'admin' , 'relative' ) , 1049 site_url ( 'dashboard' , 'relative' ) , 1050 site_url ( 'admin' , 'relative' ) , 1051 ) ; 1052 1053 if ( in_array ( untrailingslashit ( $_SERVER [ 'REQUEST_URI' ] ) , $admins , true ) ) { 1054 wp_redirect ( admin_url ( ) ) ; 1055 exit ; 1056 } 1057 1058 $logins = array ( 1059 home_url ( 'wp-login.php' , 'relative' ) , 1060 home_url ( 'login.php' , 'relative' ) , 1061 home_url ( 'login' , 'relative' ) , 1062 site_url ( 'login' , 'relative' ) , 1063 ) ; 1064 1065 if ( in_array ( untrailingslashit ( $_SERVER [ 'REQUEST_URI' ] ) , $logins , true ) ) { 1066 wp_redirect ( wp_login_url ( ) ) ; 1067 exit ; 1068 } 1069 } History Introduced in 3.4.0 . Unchanged from 6.7.7 through 7.1.0.
6.7.7 6.8.8 6.9.7 7.0.4 7.1.0 Signature, return type and hooks compared across 5 parsed releases.
About this page Parsed data Generated from the wordpress-develop 7.0.4 tag, from src/wp-includes/canonical.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. Corrections Something wrong on this page? Report it and it gets fixed in the next regeneration.