Skip to content

Instantly share code, notes, and snippets.

@mattheu
Created October 23, 2013 22:18
Show Gist options
  • Save mattheu/7127778 to your computer and use it in GitHub Desktop.
Save mattheu/7127778 to your computer and use it in GitHub Desktop.
## Fix login loop. * When WordPress is installed in a subdirectory, wp-admin/ links don't work correctly. We fix this with an nginx rewrite. * But... it appends reauth=1 to the url which forces a reauthentication when submitted... and you have to log in again!
/**
* Fix login loop.
*
* When WordPress is installed in a subdirectory, wp-admin/ links don't work correctly. We fix this with an nginx rewrite.
* But... it appends reauth=1 to the url which forces a reauthentication when submitted... and you have to log in again!
*/
add_filter( 'login_url', function( $url ) {
if ( '/wp-admin/' === add_query_arg( array() ) ) {
$url = remove_query_arg( 'reauth', $url );
$url = add_query_arg( 'redirect_to', get_admin_url(), $url );
}
return $url;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment