Created
October 23, 2013 22:18
-
-
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!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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