简体   繁体   中英

changing the wp-admin url-path, i have this function but it's not working like it should

I played around with this and I'm having trouble getting it to work. I've added it at the bottom of the functions.php file in my themes folder.. no dice.. It should be redirecting to mySecretString=foobar... When i go to wp-admin it just takes me to the admin page to login.. that page should be accessible anymore, it should only be accessible by whatever the variable $QS equals.

// 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');

Can anyone help me get this working, it seems like it should be so easy but nothing is working for me.

Thanks in advance.

I'm not understood your requirements fully where you want to exactly redirect, it would always helpful to you when you use .htaccess files in root folder, where you can do necessary redirection instead of writing functions.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM