用htaccess取消wp-admin

时间:2012-04-25 14:55:02

标签: wordpress .htaccess

我不喜欢WordPress随处可见的品牌,就像http://example.com/wp-admin一样。我更喜欢像http://example.com/admin这样的债券版本。这是否可以使用.htaccess规则?从安全性和/或可访问性的角度来看,这是一个坏主意吗?

2 个答案:

答案 0 :(得分:2)

按照以下更改进行操作:

.htaccess代码

RewriteRule ^secret-folder/(.*) wp-admin/$1?%{QUERY_STRING} [L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress-3.3/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress-3.3/index.php [L]
</IfModule>

# END WordPress

WP-config.php中

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

主题/ your_theme_name / 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);
}

add_action( 'admin_init', 'restrict_wp_admin');

function redirect_wp_admin(){
    $redirect_to = $_SERVER['REQUEST_URI'];
    if(count($_REQUEST)> 0 && array_key_exists('redirect_to', $_REQUEST)){
        $redirect_to = $_REQUEST['redirect_to'];
        $check_wp_admin = stristr($redirect_to, 'wp-admin');
        if($check_wp_admin){
            wp_safe_redirect( '404.php' );
        }
    }
} 

答案 1 :(得分:0)

请参阅How to Hide The Fact That You’re Using WordPress | Ben Word

  

•清理wp_head的输出并从中移除发生器   RSS提要

     

•隐藏/ wp-content /重写静态主题资源(CSS,JS和   图像)

     

•使用自定义助步器清理导航菜单的输出

     

•根相对网址