You can potentially use redirects to achieve this, it may not be the most ideal or stable solution, and could cause problems with your site. This is why you’re seeing a “too many redirects” error. Every time WordPress loads, it checks if the requested URL is supposed to be the admin URL. If not, it redirects you to the proper admin URL. This causes an infinite loop of redirections, leading to the error.
If you really want to do this, it’s probably better to set up a basic HTML/PHP page at your domain root that automatically logs the user in and redirects them to the admin panel.
Here’s a quick code example:
<?php
require('wp-load.php'); // adjust path as needed
$user_login = 'admin'; // change 'admin' to the username of your admin user
$user = get_userdatabylogin($user_login);
if(!is_user_logged_in()) {
wp_set_current_user($user->ID, $user_login);
wp_set_auth_cookie($user->ID);
do_action('wp_login', $user_login);
}
wp_redirect(admin_url());
exit;
?>
This will log in the admin user and redirect to the admin dashboard. You should place this code in a file in your website root (e.g., index.php
), and make sure the default document in your server configuration is set to this file.
This code is intended as a starting point and should be customized to suit your needs. Remember to handle user authentication and secure your website appropriately.
Also note that this approach has some security risks, since it essentially bypasses the WordPress login screen, and automatically logs in a user with an admin role. This is not recommended for sites on public servers or those that need to remain secure.
In any case, I would strongly recommend considering other alternatives. The standard /wp-admin path is well known and widely used, and deviating from this could lead to confusion or issues down the road. Plus, it’s always a good idea to keep the front-end available, even if only admins are using the site.