Reference › Functions wp_redirect_admin_locations ()
Since 3.4.0
Source wp-includes/canonical.php:1030Description 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 ↗
1030 function wp_redirect_admin_locations ( ) { 1031 global $wp_rewrite ; 1032 1033 if ( ! ( is_404 ( ) && $wp_rewrite -> using_permalinks ( ) ) ) { 1034 return ; 1035 } 1036 1037 $admins = array ( 1038 home_url ( 'wp-admin' , 'relative' ) , 1039 home_url ( 'dashboard' , 'relative' ) , 1040 home_url ( 'admin' , 'relative' ) , 1041 site_url ( 'dashboard' , 'relative' ) , 1042 site_url ( 'admin' , 'relative' ) , 1043 ) ; 1044 1045 if ( in_array ( untrailingslashit ( $_SERVER [ 'REQUEST_URI' ] ) , $admins , true ) ) { 1046 wp_redirect ( admin_url ( ) ) ; 1047 exit ; 1048 } 1049 1050 $logins = array ( 1051 home_url ( 'wp-login.php' , 'relative' ) , 1052 home_url ( 'login.php' , 'relative' ) , 1053 home_url ( 'login' , 'relative' ) , 1054 site_url ( 'login' , 'relative' ) , 1055 ) ; 1056 1057 if ( in_array ( untrailingslashit ( $_SERVER [ 'REQUEST_URI' ] ) , $logins , true ) ) { 1058 wp_redirect ( wp_login_url ( ) ) ; 1059 exit ; 1060 } 1061 } 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 6.8.8 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.