Welcome Guest, Not a member yet? Register   Sign In
Under Construction & block other pages in CI
#1

Hi friends,

I was searching in the forums to find how to create under construction page but i couldn't find any post that helps me to do this.

When I'm uploading my project on the host, something i need to down the website to do some uploads or maintenance. so i need to have a page to show to visitors like "under construction" page.. but the question is how to avoid of entering the controller/method to the url directly. I mean is even i set "Under construction" page as default controller, still users can enter some path to the url like (mywebsite.com/user/dashboard) .

How can i block securely all the pages during updating my app?

Thanks in advance.
Reply
#2

(This post was last modified: 01-19-2016, 09:22 PM by InsiteFX.)

See this link:

Redirect Under Construction

OR

Site Maintenance Hooks
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

The old version of Community Auth had a maintenance mode implementation that would show everyone a "Site Down for Maintenance" page, but allowed the developers full access to the site. Most of this functionality was a customization of the front controller (index.php).

See here:

https://bitbucket.org/skunkbad/community...ew-default

The important thing when serving up the maintenance mode page is to set a 503 status header. This is the page that Community Auth would serve up:

https://bitbucket.org/skunkbad/community...ew-default
Reply
#4

You could write some code in your my_controller which checks a config value. In the config you define a boolean to enable or disable the website and you define an ip whitelist.
In your my_controller you can check if you need to load the offline viewfile or just continues as normal.
Reply
#5

i think the safest way, and its actually very fast --

www.mywebsite.com/index.php
replace the codeigniter index.php with your "under construction" message
this completely eliminates any chance of someone opening up
mywebsite.com/user/dashboard

make a folder like
www.mywebsite.com/developerpreview

and put in the codeigniter index.php
www.mywebsite.com/developerpreview/index.php
the index.php in that folder points to the application folder you are working on

when you are ready to go live, replace the top level under construction page with the codeigniter index.php
pointing to the appropriate folders
Reply
#6

(01-19-2016, 10:51 PM)skunkbad Wrote: The old version of Community Auth had a maintenance mode implementation that would show everyone a "Site Down for Maintenance" page, but allowed the developers full access to the site. Most of this functionality was a customization of the front controller (index.php).

See here:

https://bitbucket.org/skunkbad/community...ew-default

The important thing when serving up the maintenance mode page is to set a 503 status header. This is the page that Community Auth would serve up:

https://bitbucket.org/skunkbad/community...ew-default

Im trying your code.
I can see you written for code igniter 2.2.2 in the maintenance-mode.php, Is it best practice for version 3.0.6 as well?
Reply
#7

(This post was last modified: 04-10-2016, 09:08 AM by PaulD. Edit Reason: Added PS )

For user login parts of the site:
Guessing that you have a live site, with users that can log in, put a little test in your login script that checks a setting in your db to see if the site is live or not. If it is not, do not log them in but redirect to a holding page view.

I also test to see if the user is a site admin user too, if so it lets me log in and go to the site like normal. Any other user gets shut out.

I also make sure the 'authorise user' script does the check too, so any already logged in users get logged out on their next page request and redirected.

For the site as a whole:
I change the index.php file name to index-off.php, and then change my construction page from index-off.html to index.html. Now the site shows the construction page. I also have a .htaccess file that I use to redirect all urls to index.html

Then I upload all the application files.

Then I change the filenames back again, and tada, the site is live again.

Manual, mechanical, but fool proof!

Best wishes

Paul.

PS Diedriks answer above with the pre-controller hook and cartalots solution are probably better solutions, I just have never done it that way but might give it a go.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB