Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

AJD on "Redirect Wordpress Login and Forgot password running from subdirectory."

$
0
0

I am trying to redirect the Wordpress login away from the standard page so it doesn't break the appearance of the site. I have read and tried many versions, but none seem to work for me.

I found the following code on another forum, but it is not working on my site. I will be adding the code via a plugin, so the redirection will look and work ok with any theme.

I am running Wordpress in a sub-directory, but without its own domain name, so it is at mysite.com/wp/ - both for site address and WP address.

I wonder if this location is causing the following code not to work.

function redirect_login_page(){

 // Store for checking if this page equals wp-login.php
 $page_viewed = basename($_SERVER['REQUEST_URI']);

 // Where we want them to go
 $login_page  = site_url();

 // Two things happen here, we make sure we are on the login page
 // and we also make sure that the request isn't coming from a form
 // this ensures that our scripts & users can still log in and out.
 if( $page_viewed == "wp-login.php" && $_SERVER['REQUEST_METHOD'] == 'GET') {

  // And away they go...
  wp_redirect($login_page);
  exit();

 }
}

add_action('init','redirect_login_page');

Thanks


Viewing all articles
Browse latest Browse all 8245

Trending Articles