Is there a way to set wp-admin at domain-root? usually you got to wp-admin @ domain.com/wp-admin I would like to have wp-admin at domain.com
Is this doable and is it done with Htaccess or what is needed?
Is there a way to set wp-admin at domain-root? usually you got to wp-admin @ domain.com/wp-admin I would like to have wp-admin at domain.com
Is this doable and is it done with Htaccess or what is needed?
I'm not quite sure what you mean by have /wp-admin at your domain root, but you can use this in your theme's functions.php to force a log-in to view the website.
// Force user login before viewing website
function force_login()
{
if ( ! is_user_logged_in() )
{
if ( is_feed() )
{
$credentials = array();
$credentials['user_login'] = $_SERVER['PHP_AUTH_USER'];
$credentials['user_password'] = $_SERVER['PHP_AUTH_PW'];
$user = wp_signon( $credentials );
if ( is_wp_error( $user ) )
{
header( 'WWW-Authenticate: Basic realm="' . $_SERVER['SERVER_NAME'] . '"' );
header( 'HTTP/1.0 401 Unauthorized' );
die();
}
}
else
{
header( 'Location: /wp-admin' );
die();
}
}
}
add_action( 'template_redirect', 'force_login' );
You can do redirect from domain.com/wp-admin
to domain.com
but the problem is after you logged in, the url will land on wp-admin/posts.php
etc., which will redirect it to domain.com again.
By this way it will create a redirect loop which will turn breaking the wp-admin.
I think its a bad idea, instead you can create a custom login page and set it as a homepage.