【问题标题】:changing the wp-admin url-path, i have this function but it's not working like it should更改 wp-admin url-path,我有这个功能,但它不能正常工作
【发布时间】:2014-02-05 17:01:51
【问题描述】:

我玩过这个,但我无法让它工作。我已将它添加到我的主题文件夹中的 functions.php 文件的底部.. 没有骰子.. 它应该重定向到 mySecretString=foobar... 当我去 wp-admin 它只是带我到管理页面登录..该页面应该可以访问了,它应该只能通过变量$QS等于访问。

// Simple Query String Login page protection
function example_simple_query_string_protection_for_login_page() {
$QS = '?mySecretString=foobar';
$theRequest = 'http://' . $_SERVER['SERVER_NAME'] . '/' . 'wp-login.php' . '?'. $_SERVER['QUERY_STRING'];

// these are for testing
// echo $theRequest . '<br>';
// echo site_url('/wp-login.php').$QS.'<br>';   

    if ( site_url('/wp-login.php').$QS == $theRequest ) {
        echo 'Query string matches';
    } else {
        header( 'Location: http://' . $_SERVER['SERVER_NAME'] . '/' );
    }
}
add_action('login_head', 'example_simple_query_string_protection_for_login_page');

谁能帮我完成这个工作,看起来应该很容易,但对我没有任何帮助。

提前致谢。

【问题讨论】:

  • 请添加更多详细信息!它应该如何工作?
  • 我添加了一些内容以防您感到困惑。

标签: php wordpress url redirect


【解决方案1】:

我没有完全理解您想要在哪里精确重定向的要求,当您在根文件夹中使用 .htaccess 文件时,它总是对您有所帮助,您可以在其中进行必要的重定向而不是编写函数。

Redirect 302 /about http://www.example.net/our-company-info/

http://www.woothemes.com/2013/11/htaccess-url-redirects/

【讨论】:

  • 我想过在 htaccess 中使用重定向,但我真的很想让这个功能工作。
  • 我认为你的函数工作正常,但你嵌入 WP 的方式不正确。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-11-06
  • 2018-06-02
  • 2022-09-27
  • 2014-10-07
  • 1970-01-01
  • 2019-02-08
相关资源
最近更新 更多