Browse Source

Add more codes to be accepted to change the htaccess see BT#12478

jmontoyaa 7 years ago
parent
commit
9090f95b74
1 changed files with 17 additions and 11 deletions
  1. 17 11
      plugin/maintenancemode/plugin.php

+ 17 - 11
plugin/maintenancemode/plugin.php

@@ -157,17 +157,13 @@ RewriteRule \.*$ '.$append.'/maintenance.html [R=302,L]
         $httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
         curl_close($handle);
 
-        // Looks htaccess contains errors. Restore as it was.
-        if ($httpCode != 200) {
-            Display::addFlash(
-                Display::return_message(
-                    'Check your htaccess instructions. The original file was restored.',
-                    'warning'
-                )
-            );
-            $originalContent = str_replace("\x0D", '', $originalContent);
-            file_put_contents($file, $originalContent);
-        } else {
+        $statusOkList = [
+            200,
+            301,
+            302,
+        ];
+
+        if (in_array($httpCode, $statusOkList)) {
             $result = file_put_contents($maintenanceHtml, $content);
             if ($result === false) {
                 Display::addFlash(
@@ -177,6 +173,16 @@ RewriteRule \.*$ '.$append.'/maintenance.html [R=302,L]
                     )
                 );
             }
+        } else {
+            // Looks htaccess contains errors. Restore as it was.
+            Display::addFlash(
+                Display::return_message(
+                    'Check your htaccess instructions. The original file was restored.',
+                    'warning'
+                )
+            );
+            $originalContent = str_replace("\x0D", '', $originalContent);
+            file_put_contents($file, $originalContent);
         }
 
         if ($active == false) {