質問

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

役に立ちましたか?

解決

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;
  }
}

他のヒント

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.

ライセンス: CC-BY-SA帰属
所属していません drupal.stackexchange
scroll top