I created a custom login page with custom path (www.example.com/customlogin) and blocked access to default login page via hook_menu_alter(). The requirement for default login page to return 403 is achieved.

Login page accessed via new path works great, but this page is inaccessible when the website is in maintenance mode.

Question: How to make a path accessible in maintenance mode?

I'd like to find a method that does not require the use of additional modules like Rename Admin Path

  • Is this an issue where you cannot administer the site while it is in maintenance mode? Users should not be logging in while the site is in maintenance. Is drush uli not an option? Apr 19, 2016 at 16:13
  • @DeveloperWeeks, website has multiple admins/editors, most of them do not work in CLI, so there is a need to have them access via login form while website is in maintenance mode. Thanks.
    – oksana-c
    Apr 19, 2016 at 16:27

2 Answers 2


A viable solution for making the path/URL/page available while in maintenance mode is the use of hook_menu_site_status_alter().

This hook is called after checking whether the site is offline (in maintenance mode) but before the current router item is retrieved and executed.

Code below should be used in a custom module:

function CUSTOMMODULE_menu_site_status_alter(&$menu_site_status, $path) {
  // Allow access to my_module/authentication even if site is in offline mode.
  if ($menu_site_status == MENU_SITE_OFFLINE && user_is_anonymous() && $path == 'custom-path') {
    $menu_site_status = MENU_SITE_ONLINE;
  • Good hook find ... there is a hook for everything in drupal and that is one I have never even read about before, let alone use. Apr 20, 2016 at 18:38

Change the access value in your hook_menu_alter() to

'access callback' => variable_get('maintenance_mode',0),

This way, the normal user login page returns when you change to maintenance mode, but you retain the 403. I have not tested this method.

The issue in general here is that maintenance mode is designed to prevent access to the site while it is in a vulnerable or unstable state. Yet, you have multiple people who have not signed in, thus "anonymous" user session right now, that you want to give access. If you grant the Use the site in maintenance mode permisison to anonymous user then the site will behave as you request... but that removes the reason for having maintenance mode. I think you need to have a second server where you can do the maintenance test, and then use tagged git states to deploy to the production site.

Maintenance mode just does not work for the arrangement that you have described.

  • @DevelopeWeeks , I tested your approach, and it somewhat works. But the issue is that access_callback that is set via hook_menu_alter() can be changed only after clearing cache or by invoking menu_router_build(), as the data is saved to the {menu_router} table. So, when the maintenance mode is changed, the callback for the page is staying the same until the cache is cleared.
    – oksana-c
    Apr 20, 2016 at 15:46
  • I appreciate your input on best practices and I am aware of the proper use of maintenance mode. The format of QA will not support me rambling on how I am going to use it in my specific application, so I will go with my own judgement as to the arrangement that I briefly described. The question was merely on how to make a path available in maintenance mode. Thank you for ideas on this. It prompted me to dig in a right direction, I'll post the solution I found.
    – oksana-c
    Apr 20, 2016 at 15:48
  • If time allows, please comment on the answer I provided.
    – oksana-c
    Apr 20, 2016 at 15:53

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.