Change Wordpress Admin URL

后端 未结 6 1949
遇见更好的自我
遇见更好的自我 2020-11-28 11:37

I changed my Wordpress directory structure quite a bit. Here\'s what I have:

define(\'WP_SITEURL\', \'http://\' . $_SERVER[\'SERVER_NAME\'] . \'/wordpress\'         


        
6条回答
  •  醉酒成梦
    2020-11-28 11:57

    Here's an article from wordpress's site.

    http://wordpress.org/support/topic/how-to-change-the-admin-url-or-wp-admin-to-secure-login

    1. Add constant to wp-config.php

      define('WP_ADMIN_DIR', 'secret-folder');  
      define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . WP_ADMIN_DIR);  
      
    2. Add below filter to functions.php

      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);  
      }
      
    3. Add below line to .htaccess file

      RewriteRule ^secret-folder/(.*) wp-admin/$1?%{QUERY_STRING} [L]
      

提交回复
热议问题