Is there any simple way to have wordpress, php or apache rewrite all urls which involve /wp-admin to /admin?

I have added this entry to my .htaccess file:

RewriteRule ^admin /wp-login.php [L]

However although domain.com/admin will correctly show the login page all pages after you login show the URL as /wp-admin which I want to always show /admin.

Any thoughts on this?

  • possible duplicate of Can I rename the wp-admin folder?
    – Rarst
    Commented Nov 14, 2010 at 12:15
  • @Rarst -- I saw that one but I figured my question was more targeted and might allow someone to answer the question as it seems like this should somehow be possible in a round about way... Commented Nov 14, 2010 at 12:25
  • Unless I am misunderstanding something your question is currently worded as exactly about changing wp-admin to admin, which is not possible according to answers on that other question. If you want to achieve something else please write it out a bit?..
    – Rarst
    Commented Nov 14, 2010 at 12:40
  • 1
    @Rarst -- Are you sure there is no php, apache or wordpress way to get all backend links which point to /wp-admin to point to a different directory? I know that through mod-rewrite once can create an alias folder and define all content for that folder to be pulled from a different location. Thus I figured there must be some way to force wordpress to write those urls instead of /wp-admin... thats the question I am after. Do you still suggest the rewrite? Commented Nov 14, 2010 at 15:41

3 Answers 3


To answer you question as a apache URL layout configuration via mod_rewrite (the apache module that handles URL rewriting), this could be helpful:

RewriteRule ^admin/(.*)$ /wp-admin/$1 [QSA,L]

(untested configuration directive, check the docs in case this does errors)

This will basically translate any request to /admin/... into /wp-admin/... .

If that's the only thing you would like to know, I must admit that this is slightly off-topic for worpdress@se as this is acutally a question how to configure the apache webserver. A better place might be serverfault.

Keep in mind that this only rewrites the URLs that get requested. Wordpress would know nothing about this and it does still output links to /wp-admin/ on the admin then. There is a hook for any admin URL that you might want to rewrite then as well:

return apply_filters('admin_url', $url, $path, $blog_id);

You would need to replace the domain/wp-admin/ part with domain/admin/ with a filter on your own.

  • @hakre -- Thank you, this is basically exactly what I was looking for. The area I am less familiar with is the apply_filters aspect. I am assuming this gets placed into the functions.php file towards the top correct? Could you possibly provide a example of this wordpress line which would automativcally modify all /wp-admin/(.*) request to /admin/(.*) Commented Nov 15, 2010 at 5:00
  • 3
    It's a bit more complex, as it needs to do some additional settings as well. I've created a must-use plugin for reference: gist.github.com/701245#file_change_admin_url.php
    – hakre
    Commented Nov 16, 2010 at 0:39
  • @hakre -- I have tried the code you posted on github but this did not seem to work for me. For some strange reason I was not even able to see the plugin. What I did notice is that you said to place it in the mu-plugins folder but I am assuming placing it in your regular plugins folder (without mu in place) will work as well (even if you changed the name of the plugin folder (defined through the wp-config file)? Commented Nov 19, 2010 at 16:04
  • If created and placed correctly into the must use plugin folder, you should be able to see the filename listed unter the "Must Use" tab under Plugins: tinypic.com/view.php?pic=2h4mclc&s=7 - Otherwise I would not wonder about that it is not working. First get it there. Don't forget to configure the .htaccess file as well.
    – hakre
    Commented Nov 19, 2010 at 17:31
  • @Rarst -- I just revisited this again and noticed that it was actually me that was doing things wrong. Once I placed the code into mu-plugins it worked! Two follow up questions please... how can I modify your code so that I can just write it into my functions.php file instead? The next question is... how can I make all requests to /wp-admin, /wp-admin/index.php and /wp-login.php give a 404 error? My goal is to make it so that only /admin or /admin/index.php gives a user a login page and all others provide an error Commented Nov 24, 2010 at 17:22

hakre.... Great answer... now with the latest version of wordpress having a separate network admin I used your solution and added in the part to properly rewrite the "Network Admin" links in the same way...

     * Change Admin URL
     * Copyright (C) 2010  hakre <http://hakre.wordpress.com/>
     * This program is free software: you can redistribute it and/or modify
     * it under the terms of the GNU Affero General Public License as
     * published by the Free Software Foundation, either version 3 of the
     * License, or (at your option) any later version.
     * This program is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * GNU Affero General Public License for more details.
     * You should have received a copy of the GNU Affero General Public License
     * along with this program.  If not, see <http://www.gnu.org/licenses/>.
     * USAGE: 
     * Copy the file into  wp-content/mu-plugins  directory and add the 
     * following RewriteRule to your apache configuration or .htaccess:
     *  RewriteRule ^admin/(.*)$ wp-admin/$1 [QSA,L]
     * It will rewrite the wordpress admin-URL 
     *   from: http://example.com/wp-admin/ ...
     *   to  : http://example.com/admin/ ...
     * @author hakre <http://hakre.wordpress.com>
     * @see http://wordpress.stackexchange.com/questions/4037/how-to-redirect-rewrite-all-wp-login-requests/4063
     * @todo mod_rewrite_rules - filter to insert into .htacces on plugin activation
    /** Updated version my Mark Figueredo, <http://gruvii.com/> **/
    return ChangeAdminUrlPlugin::bootstrap();

    class ChangeAdminUrlPlugin {
     private $renameFrom = 'wp-admin';
     private $renameTo = 'admin';
     static $instance;
     static public function bootstrap() {
      null === self::$instance
       && self::$instance = new self()
      return self::$instance;
     private function setCookiePath() {
      defined('SITECOOKIEPATH') || define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/' ) );
      defined('ADMIN_COOKIE_PATH') || define('ADMIN_COOKIE_PATH', SITECOOKIEPATH . $this->renameTo);
     public function __construct() {
      add_action('init', array($this, 'init')) ;
     public function init() {
      add_filter('admin_url', array($this, 'admin_url'), 10, 3);
      add_filter('network_admin_url', array($this, 'network_admin_url'), 10, 3);//Added by Mark Figueredo, <http://gruvii.com/>
     public function admin_url($url, $path, $blog_id) {
      $renameFrom = $this->renameFrom;
      $renameTo = $this->renameTo;
      $scheme = 'admin';
      $find = get_site_url($blog_id, $renameFrom.'/', $scheme);
      $replace = get_site_url($blog_id, $renameTo.'/', $scheme);
      (0 === strpos($url, $find))
       && $url = $replace.substr($url, strlen($find))
      return $url;
// Added by Mark Figueredo, <http://gruvii.com/> 
     public function network_admin_url($url, $path) {
      $renameFrom = $this->renameFrom;
      $renameTo = $this->renameTo;
      $scheme = 'admin';
      $find = network_site_url($renameFrom.'/', $scheme);
      $replace = network_site_url($renameTo.'/', $scheme);
      (0 === strpos($url, $find))
       && $url = $replace.substr($url, strlen($find))
      return $url;
  • did you experience any issues or problems with this code? I was noticing pages taking longer to load on the admin area and some plugins where operating a bit strange... Commented Jan 26, 2011 at 14:45
  • Hello ! Just now I found this post when searching for a solution to replace ' wp- '. Could any one tell me if there is any problem using this code as @Netcontrucor.com said? Thanks !
    – user391
    Commented Jan 30, 2011 at 16:21
  • It seems your code does not work if wordpress is installed on a subdomain as it seems to try to redirect to the root domain name. Can you confirm this and if so please update this code? Thanks, CH Commented Feb 1, 2011 at 15:58
  • Please add urls of the subdomains etc. otherwise it's hard to say // I can imagine that cookies aren't working for changing domains with the current code properly.
    – hakre
    Commented Feb 7, 2011 at 23:47
  • Hey, where exactly do I put the RewriteRule inside of htaccess with relation to the other wordpress rules?... DOes it matter?
    – trusktr
    Commented Jun 17, 2011 at 6:32

In addition to the previous solutions. I found the missing css and script files.

the fix is

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

# Fix using the previous answer. 
RewriteRule ^admin/(.*)$ wp-admin/$1 [QSA,L] 

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]

#Fix to load css js image files for multi site admin urls. 
#old code RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.(php|css|js|png|jpg|gif))$ $1 [L]

RewriteRule . index.php [L]
  • thanks, have you experience any issues or limitations using this approach? Commented Nov 26, 2011 at 3:47
  • I would imagine any plugins that don't abide by WP standards will not work.
    – Ken Prince
    Commented May 26, 2015 at 12:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.