---
title: Add Custom URL Redirects to Your WordPress Dashboard Areas or Login Page
date: 2012-02-20T10:00:30+00:00
modified: 2012-02-23T14:12:03+00:00
permalink: https://kaspars.net/blog/custom-redirect-to-wordpress-login-dashboard
post_type: post
author:
  name: Kaspars
  avatar: https://reverse.kaspars.net/gravatar/avatar/92bfcd3a8c3a21a033a6484d32c25a40b113ec6891f674336081513d5c98ef76?s=96&d=mm&r=g
post_tag:
  - PHP
  - Snippet
category:
  - WordPress
---

# Add Custom URL Redirects to Your WordPress Dashboard Areas or Login Page

Ever wanted to use something like `example.com/backend` or `example.com/dash` to access your WordPress dashboard or login area? Here is a simple snippet of PHP for your *functionality* plugin or `functions.php` to do just that — it uses standard WordPress URL rewrite API.

**Update:** turns out that in WordPress 3.4 there are new default redirects (`/admin`, `/dashboard` and `/login`) implemented in the core (see [this ticket](http://core.trac.wordpress.org/changeset/19880)). So here is a better way to add your own redirects which will work only if you don’t have a page or post with the same name (slug) already:

### Updated Version:

```
add_action('template_redirect', 'add_my_custom_redirects');

function add_my_custom_redirects() {
	if (!is_404())
		return;

	$current_uri = untrailingslashit($_SERVER['REQUEST_URI']);
	$my_admin_uris = array(
		home_url('dash', 'relative'),
		home_url('your-custom-uri', 'relative')
	);

	if (in_array($current_uri, $my_admin_uris)) {
 		wp_redirect(admin_url());
 		exit;
	}
}
```

### The Obsolete Version:

```
add_filter('generate_rewrite_rules', 'add_my_custom_rewrites');

function add_my_custom_rewrites($wp_rewrite) {
    $my_rewrites = array(
	'dash' => 'wp-admin'
    );

    $wp_rewrite->rules = $my_rewrites + $wp_rewrite->rules;
}
```