I have a wordpress site works good over than 3 years. Recently I actived https for it. After that, when I visit the dashboard, I always be redirected to login page.

I found this on Codex:

Secure HTTPS

If you are having a problem with secure HTTPS, change the following line in wp-includes/vars.php from:

define('COOKIEPATH', preg_replace('|http://[^/]+|i', '', get_settings('home') . '/' ) );


define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_settings('home') . '/' ) );

Be sure also to change the URL in OPTIONS to https://.

But I cannot find define('COOKIEPATH', preg_replace('|http://[^/]+|i', '', get_settings('home') . '/' ) ); in the vars.php. My wordpress's version is 4.7.

In the functions.php, I use this action to prevent users visit the dashboard:

add_action('init', 'IUI_prevent_backend');
function IUI_prevent_backend() {
  global $pagenow;

  if($pagenow == 'wp-login.php') {

    $page = home_url('/login');

  } elseif (is_admin() && !(defined('DOING_AJAX') && DOING_AJAX) && !current_user_can('edit_posts') && !current_user_can('edit_events')) {

    $page = home_url('/login');


I tried to remove this action and nothing changes. I don't think it's the case.


You should read the codex on Administration Over SSL and also shouldn't edit the core wordpress files as it isn't advised and your edits get overwritten on update.

You should define FORCE_SSL_ADMIN in your wp-config.php

define('FORCE_SSL_ADMIN', true);
  • I did. It doesn't help. – Brick Yang Jan 4 '17 at 10:23
  • Does the main site work as it should over https? and are you using a reverse proxy? – Tunji Jan 4 '17 at 10:26
  • Yes. The main site works fine. I am using Nginx. – Brick Yang Jan 4 '17 at 10:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.