zoukankan      html  css  js  c++  java
  • hide your website's wordpress info/path/way

    Hide Wordpress Info of your website

    plugin hide-wp

    使用apache语句和wp方法重写
    但这个插件有个局限就是,你的网站使用的wordpress的话,必须wp的根目录就是你的网站根目录。
    如果你一个网站部署了多个wordpress的话,用不同的目录区分的话,例如,

    www.baidu.com/ofo/
    www.baidu.com/hptv/
    

    这两个目录ofo和hptv分别是一个完整的wordpress的话,就会出错


    but,这个插件极其简单,只有两个文件

    OK

    hide-wp-admin.php是修改.htaccess的apache语句路由

    OK

    hide-wp.php是重写wordpress的用到路径的方法

    OK

    所以必须先修改hide-wp-admin.php在每个语句的Rewrite的destination前面加上你的目录,使得

    RewriteRule ^style.css /wp-content/themes/vortex/style.css [L,QSA]
    

    成为

    RewriteRule ^style.css /ofo/wp-content/themes/vortex/style.css [L,QSA]
    

    还有就是,如果你的functions.php文件中使用了get_stylesheet_directory_uri()方法,可能会使所有使用该方法的样式和JS文件都无法加载,一般是因为多加了base路径,例如,本来应该是/ofo/home/style.css的,结果是/ofo/ofo/home/style.css了。
    所以需要把多余的那部分去掉

    function g_base()
    {
    	$slashed_home = trailingslashit( get_option('home') );
    	$base = parse_url( $slashed_home, PHP_URL_PATH );
    	$base = str_replace('/','',$base);
    	return $base;
    }
    function get_stylesheet_directory_uri_clean() {
        $stylesheet_dir_uri = get_stylesheet_directory_uri();
        $reg = '(^/'.g_base().')'; #"/". $this->g_base().')';
        $stylesheet_dir_uri = preg_replace($reg, '', $stylesheet_dir_uri);
        return $stylesheet_dir_uri;
    }
    

    然后使用get_stylesheet_directory_uri()的地方都是用get_stylesheet_directory_uri_clean()代替

    现成的

    我修改过的 here,挂载于 renlab


  • 相关阅读:
    2017暑期集训Day 1
    17-06-28模拟赛
    17-06-26模拟赛
    平衡树学习笔记
    指针学习笔记
    17-06-14模拟赛
    17-06-11模拟赛
    17-06-02模拟赛
    17-05-31模拟赛
    培训补坑(day1:最短路&two-sat)
  • 原文地址:https://www.cnblogs.com/raybiolee/p/5713306.html
Copyright © 2011-2022 走看看