Asked  7 Months ago    Answers:  5   Viewed   30 times

I have built a website (PHP) with more than 60 pages. I have only now realized (unfortunately) that I should have built in an "In Maintenance Mode" feature to allow an admin to temporarily disable the website and point it to a Maintenance Mode page. This would only allow those logged in as an admin to view the website.

The options I see are:

  1. Add a new "include" file to the top of every single PHP page.

  2. I have one include that is used to display the navigation bar on
    every page (navigation class). I could write the Maintenance Mode
    code in this class.

Do I have any other options? The 1st option doesn't seem like the most efficient, and the 2nd one just seems like bad programming. Is there any other better way to include a new file on every single php file?

Thanks!

ps - the site is not launched yet

 Answers

19

You can use .htaccess to redirect to another page while on Maintenance Mode.

Three assorted examples:

RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^11.111.111.111
RewriteCond %{REQUEST_URI} !^/maintenance.html$
RewriteRule ^(.*)$ http://domain.com/maintenance.html [R=307,L]

.htaccess “Down For Maintenance” Page Redirect

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !/maintenance.html$ 
RewriteCond %{REMOTE_HOST} !^888.888.888.888

RewriteRule $ /maintenance.html [R=302,L] 

Redirect to maintenance page during upgrade using .htaccess

# redirect all visitors to alternate site but retain full access for you
ErrorDocument 403 http://www.alternate-site.com
Order deny,allow
Deny from all
Allow from 99.88.77.66

Maintenance mode for apache

Wednesday, March 31, 2021
 
Skipper
answered 7 Months ago
87

I haven't tested anything but simply looking at that line...

RewriteRule ^/?([a-zA-Z0-9-_]+)/?$ /index.php?loadPage=$1&mode=cms [QSA,L]

there is a syntax error. The hyphen after the 9 should be escaped as technically that is a range indicator. Most of the time you see people place it at the end before the ] and so it doesn't cause an error and so most people think they don't have to escape it. You also do not need to escape the forward slashes. Also using the question mark makes the previous optional, and don't know why you want that. So it should be like this:

RewriteRule ^([a-zA-Z0-9-_]+)/?$ /index.php?loadPage=$1&mode=cms [QSA,L]
Wednesday, March 31, 2021
 
Claudio
answered 7 Months ago
88

Use THE_REQUEST instead of REQUEST_URI which might change due to other modules or rules:

RewriteEngine On

RewriteCond %{HTTPS} off
RewriteCond %{THE_REQUEST} !s/+preview [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]

RewriteCond %{HTTPS} on
RewriteCond %{THE_REQUEST} s/+preview [NC]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]

# other rules go here

Also make sure to clear your browser cache.

Saturday, May 29, 2021
 
RenegadeAndy
answered 5 Months ago
24

Finally, I am able to implement. Following are the steps I have done

  • Login in App1
  • Get Option to Login with App2
  • Click on “Login with App2”
  • Redirects to the Login screen of App2
  • On click of Login button of App2 that redirects to the SSOInMVCWcfService. Here, method Login calls the method Authenticate of the service of App1 i.e. SSOAuthService. If authenticated then generates token for this username and also retrieves the userid from the service of App1.
  • Once token generated and user id retrieved for this Authenticated user, these values are entered in the table say ‘SessionDetails’ in database.
  • Then send the userid and token for the current user to App2.
  • Now App2 sends the returnurl i.e. the authenticated page url of app1 alongwith the userid and token to the login page of App1 by adding these values as cookies in the Response Object.
  • Now on the App1 login page, these cookies are retrieved and on the base of the userid the current username is retrieved from the “SessionDetails” table.
Wednesday, August 4, 2021
 
Shawson
answered 3 Months ago
77

Apparently iOS 8 includes a certificate-support that allows the use of certificate-based single sign-on for users to authenticate to enterprise apps.

Accounts Framework

The Accounts framework (Accounts.framework) provides a single sign-on model for certain user accounts. Single sign-on improves the user experience by eliminating the need to prompt the user separately for multiple accounts. It also simplifies the development model for you by managing the account authorization process for your app. You use this framework in conjunction with the Social framework.

So you should take a look in Accounts Framework Reference

Wednesday, October 13, 2021
 
Willy
answered 2 Weeks ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :