Title: wp_redirect_admin_locations
Published: April 25, 2014
Last modified: May 20, 2026

---

# wp_redirect_admin_locations()

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_redirect_admin_locations/?output_format=md#description)
 * [Source](https://developer.wordpress.org/reference/functions/wp_redirect_admin_locations/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_redirect_admin_locations/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_redirect_admin_locations/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_redirect_admin_locations/?output_format=md#wp--skip-link--target)

Redirects a variety of shorthand URLs to the admin.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_redirect_admin_locations/?output_format=md#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.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_redirect_admin_locations/?output_format=md#source)󠁿

    ```php
    function wp_redirect_admin_locations() {
    	global $wp_rewrite;

    	if ( ! ( is_404() && $wp_rewrite->using_permalinks() ) ) {
    		return;
    	}

    	$admins = array(
    		home_url( 'wp-admin', 'relative' ),
    		home_url( 'dashboard', 'relative' ),
    		home_url( 'admin', 'relative' ),
    		site_url( 'dashboard', 'relative' ),
    		site_url( 'admin', 'relative' ),
    	);

    	if ( in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ), $admins, true ) ) {
    		wp_redirect( admin_url() );
    		exit;
    	}

    	$logins = array(
    		home_url( 'wp-login.php', 'relative' ),
    		home_url( 'login.php', 'relative' ),
    		home_url( 'login', 'relative' ),
    		site_url( 'login', 'relative' ),
    	);

    	if ( in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ), $logins, true ) ) {
    		wp_redirect( wp_login_url() );
    		exit;
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/canonical.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/canonical.php#L1038)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/canonical.php#L1038-L1069)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_redirect_admin_locations/?output_format=md#related)󠁿

| Uses | Description | 
| [untrailingslashit()](https://developer.wordpress.org/reference/functions/untrailingslashit/)`wp-includes/formatting.php` |

Removes trailing forward slashes and backslashes if they exist.

  | 
| [wp_redirect()](https://developer.wordpress.org/reference/functions/wp_redirect/)`wp-includes/pluggable.php` |

Redirects to another page.

  | 
| [wp_login_url()](https://developer.wordpress.org/reference/functions/wp_login_url/)`wp-includes/general-template.php` |

Retrieves the login URL.

  | 
| [is_404()](https://developer.wordpress.org/reference/functions/is_404/)`wp-includes/query.php` |

Determines whether the query has resulted in a 404 (returns no results).

  | 
| [site_url()](https://developer.wordpress.org/reference/functions/site_url/)`wp-includes/link-template.php` |

Retrieves the URL for the current site where WordPress application files (e.g. wp-blog-header.php or the wp-admin/ folder) are accessible.

  | 
| [WP_Rewrite::using_permalinks()](https://developer.wordpress.org/reference/classes/wp_rewrite/using_permalinks/)`wp-includes/class-wp-rewrite.php` |

Determines whether permalinks are being used.

  | 
| [admin_url()](https://developer.wordpress.org/reference/functions/admin_url/)`wp-includes/link-template.php` |

Retrieves the URL to the admin area for the current site.

  | 
| [home_url()](https://developer.wordpress.org/reference/functions/home_url/)`wp-includes/link-template.php` |

Retrieves the URL for the current site where the front end is accessible.

  |

[Show 3 more](https://developer.wordpress.org/reference/functions/wp_redirect_admin_locations/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_redirect_admin_locations/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_redirect_admin_locations/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.4.0](https://developer.wordpress.org/reference/since/3.4.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_redirect_admin_locations%2F)
before being able to contribute a note or feedback.