更改 Wordpress 管理 URL [英] Change Wordpress Admin URL

查看:31
本文介绍了更改 Wordpress 管理 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我改变了我的 Wordpress 目录结构.这是我所拥有的:

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

define('WP_SITEURL', 'http://' . $_SERVER['SERVER_NAME'] . '/wordpress');
define('WP_HOME',    'http://' . $_SERVER['SERVER_NAME']);
define('WP_CONTENT_DIR', dirname(__FILE__) . '/content');
define('WP_CONTENT_URL', 'http://' . $_SERVER['SERVER_NAME'] . '/content');

所以我有一个 content 目录,其中包含我的插件和主题.然后我有一个 wordpress 目录,其中包含核心 WP 文件,减去 wp-content 文件夹.

So I have a content directory which contains my Plugins and Themes. And then I have a wordpress directory which contains the core WP files, minus the wp-content folder.

使用这种新结构,我必须使用以下 URL 访问 WP 后端:http://site.dev/wordpress/wp-admin

With this new structure, I have to access the WP backend with this URL: http://site.dev/wordpress/wp-admin

有没有办法改变它,这样我就可以像这样访问它:http://site.dev/wp-admin

Is there a way I can change it so I can just access it like so: http://site.dev/wp-admin

我不希望 wordpress 出现在 URL 中.这是我需要进行的 htaccess 更新,还是我可以在 wp-config.php 文件中使用的设置?

I don't want wordpress to be in the URL. Would this be an htaccess update I need to make, or is there a setting I can use in my wp-config.php file?

推荐答案

这是一篇来自 wordpress 网站的文章.

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. 将常量添加到 wp-config.php

  1. Add constant to wp-config.php

define('WP_ADMIN_DIR', 'secret-folder');  
define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . WP_ADMIN_DIR);  

  • 将以下过滤器添加到functions.php

  • 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);  
    }
    

  • 在 .htaccess 文件中添加以下行

  • Add below line to .htaccess file

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

  • 这篇关于更改 Wordpress 管理 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆