My client wants the only login url to be /user/login So I need to redirect /user to /user/login

any idea how to accomplish this?

  • 3
    You should consider that '/user' url can be access by authenticated user also. So, if you redirect '/user' to '/user/login', then its should be redirect to only anonymous user, not authenticated user. Commented Apr 1, 2014 at 10:58
  • @JayendraKainthola no problem. but how do i redirect? Commented Apr 1, 2014 at 11:06
  • possible duplicate of How to direct a specific role to a specific page - "anonymous" and "authenticated" are roles, too.
    – Mołot
    Commented Apr 1, 2014 at 11:20

3 Answers 3


You can use rules module to create a redirect when anonymous user view the /user page.

The Rules module allows site administrators to define conditionally executed actions based on occurring events (known as reactive or ECA rules). It's a replacement with more features for the trigger module in core and the successor of the Drupal 5 workflow-ng module.

You can follow below step:

  • Go to Administration -> Configuration -> Workflow -> Rules
  • Click on Add new rule link in top of page
  • Fill the name and select Drupal is initializing from React on Event drop down in the form and save the form.
  • click on Add Condition link in the page and select User has role(s) from the "Condition to add" drop-down and select anonymous user as user role and save the form.
  • Click on Add condition link and select "Data comparison" from the "Condition to add" drop-down and set site:current-page:path as "Data selector" and click on continue button and set 'user' in the value field and save the form.
  • Click on Add Action link and select Page redirect event and set user/login in the value field and save the form.

You can use the hook_menu_site_status_alter():

 * Implements hook_menu_site_status_alter().
function MODULENAME_menu_site_status_alter(&$menu_site_status, $path) {
  if (user_is_anonymous()) {
    if ($path == 'user') {

Here is an example on how another module implement this hook.

  • 1
    Please don't post code-only answer. This only helps someone if they know what to do with the code; it doesn't help them understand why the code solves the problem.
    – Shawn Conn
    Commented Sep 20, 2015 at 22:30

Option 1: Refer the https://www.drupal.org/project/rename_admin_paths module. The purpose of this module is to secure drupal backend by overriding admin path.

Option 2: You can also redirect /user to /user/login by writing redirect rule in .htaccess file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.