Change WordPress admin URL without plugin
WordPress is the most common CMS system and perhaps the easiest to work with him. Unfortunately most popular platforms for content management is often attacked. One of the most important things in creating a new WordPress site is to secure, using different test methods and plugins. In a series of articles we will show you different techniques that will make secure your website.
In this article I will introduce you how in a few steps to change the address of the administrator folder without using additional plugin.
1. Create a new folder in the directory of the site with a name known only to you, exm: “secretadminfolder”
2. Define the folder as administrator in wp-config file:
define('WP_ADMIN_DIR', 'secretadminfolder'); define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . WP_ADMIN_DIR);
3.Rewrite directory in .htaccess file by adding the following directive:
RewriteRule ^secretadminfolder/(.*) wp-admin/$1?%{QUERY_STRING} [L]
4. Adding features at the end of wp-includes/functions.php file:
/* change wp-admin of WP_ADMIN_DIR */
add_filter('site_url', 'wpadmin_filter', 10, 3); function wpadmin_filter( $url, $path, $orig_scheme ) { $old = array( "/(wp-admin)/"); $admin_dir = WP_ADMIN_DIR; $new = array($admin_dir); return preg_replace( $old, $new, $url, 1); }
/*wp-admin, hide address, error 404*/
add_action( 'init', 'block_wp_admin' ); function block_wp_admin() { if(strpos($_SERVER['REQUEST_URI'],'wp-admin') != false){ wp_redirect( home_url().'/404' ); exit; } }
That’s all. Now when you try to access wp-admin directory will out 404 or page that you specify in the last function, also in admin panel you will enter at: www.yoursite.com/secretadminfolder