Jump to content

Module: Maintenance Mode


Pete

Recommended Posts

The default header code for redirects in PW is a 302 redirect (page has temporarily moved) which is actually the default code for a redirect in PHP itself.

Just wanted to mention that the default for $session->redirect($url) in PW is a 301 (permanent) redirect. If you want a 302 redirect then give it a second param of false, i.e.

<?php
$this->session->redirect('http://processwire.com'); // 301 permanent redirect
$this->session->redirect('http://processwire.com', false); // 302 temporary redirect

http://processwire.com/api/variables/session/

Link to comment
Share on other sites

  • 4 months later...

Cheers Steve

I'll merge that soon as it's very useful! There was a looping issue mentioned under very specific circumstances (something about a user who's not a superuser getting an infinite redirect) by someone recently too so I'll investigate that at some point next week and put any and all changes into a new version.

Link to comment
Share on other sites

  • 5 months later...
  • 7 months later...

I like the module a lot. Thank you for this!

One idea: I would find a 2 step maintenance extremely useful: 

a) EMERGENCY - Leave only the Superadmin in (as it is now) - good for updates and for working on the database.

b) NORMAL MAINTENANCE - apply a new Permission "bypass_maintenance" to a role which is given access to the backend next to the Superadmin. - good for developing.

Link to comment
Share on other sites

  • 3 weeks later...

Updated this to v1.0.6.

You can now add optional roles that can bypass maintenance mode (superuser will always bypass regardless of whether it's selected or not!).

@ceberlin - this should help with your scenario :)

  • Like 2
Link to comment
Share on other sites

  • 3 weeks later...

Hi everybody,

quick update: I downloaded last version of the module and set the site in "Maintenance Mode" (with an exception for Superuser and guest): unfortunately the site was still visible to everybody...

did I miss anything?

If I remember well, last version worked like a charme...

Link to comment
Share on other sites

Hi Soma,

I know that superuser will always bypass but I wanted to add another user with "guest" role.

Doing this, (I tested it again) the site becomes visible to everybody.

How to show the site to a guest role without giving him full permissions?

Link to comment
Share on other sites

.....but I wanted to add another user with "guest" role.

Doing this, (I tested it again) the site becomes visible to everybody.

How to show the site to a guest role without giving him full permissions?

Am confused. Guest has view rights and that is everybody - the public. If you want the guest to view the site, it beats the logic of placing it in maintenance mode. Also, what are these full permissions for the guest? The full extent of the guest user's permissions is page-view. The only role they have is view pages. Are you talking of another user next to the superuser as requested in post #33?

Link to comment
Share on other sites

hi kongondo,

Are you talking of another user next to the superuser as requested in post #33?

short answer: yes.

As Pete said, I'd like to add an optional role that can bypass maintenance mode, but I don't want to give him the possibility to edit, delete or move pages. It's only a preview for a client before I teach him how to use PW.

How can it be done?
 

Link to comment
Share on other sites

Marco,

I haven't used this module, but from looking at the code, I think you will first need to create a role (e.g. "client"). Give that role the limited permissions you want. Create a user, e.g. "paul" and assign "paul" to the role "client". Then, in the module, add "client" as the role to bypass. 

Link to comment
Share on other sites

  • 5 months later...

HI Pete,

now I am using the DEV version. There is something funny:

I set the module to redirect to the login page (default behavior).

The "is in maintenance" info appears twice at the login screen. Maybe one time with the redirect and one time calculated new.

Because it is only one time after I refresh the login page.

Another idea: It would be great if the switch to put the maintenance mode on and off would be more accessible as a separate admin "setup" page and available to certain user roles - and not buried in the module's settings.

Link to comment
Share on other sites

Agree. It should definitely have a class. And styling should be in an external css and not inline. @ceberlin, I think the best thing for you to do is to add the class on the module itself.

Link to comment
Share on other sites

  • 2 months later...

Great to know a module like this exists :)

Another alternative is to modify the .htaccess file and do a temporary redirect 302 to say a html file at the root called /maintenence.html and then when the site is out of it, edit the .htaccess file to no longer redirect everything to that page and then do a permanent redirect 301 back to the regular homepage / for anyone going to maintenence.html. The visitors won't know any difference

Now you might ask, how the admins would login, well if you know your IP address you can allow just that IP to not be redirected

Another alternative, is to only redirect everything but whats in your /admin/ directory (whatever you have it named, hopefully something else), granted noone would be able to preview the site

  • Like 2
Link to comment
Share on other sites

 Now you might ask, how the admins would login, well if you know your IP address you can allow just that IP to not be redirected

I don't have a static IP and I use a special string within the UserAgent, for example:

RewriteCond %{HTTP_USER_AGENT} !^.*(b346a0b6fe9d440d68e07c9619c0ba0a).*$

This way (with switching UserAgent of the browser) I am able to look to the site as admin and like the public from the same IP.

  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...