0

After some research I have found that the .htaccess code to show a mantainance mode is the following:

# BEGIN MAINTENANCE MODE
# <IfModule mod_rewrite.c>
#  RewriteEngine on
#  RewriteCond %{REMOTE_ADDR} !^111\.111\.111\.111
#  RewriteCond %{REQUEST_URI} !maintenance.html$ [NC]
#  RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC] 
#  RewriteRule .* maintenance.html [R=302,L]
# </IfModule>
# END MAINTENANCE MODE

It kind of works alright, but once I am in the homepage using my computer (which is the only one that loads the actual site) and I try to go to another page within the site (Example: homepage is hello.com and another page is hello.com/blog) it will redirect me to the maintenance mode (which, for me, is a PDF file).

In other words, the homepage loads with my IP, but all of the other pages of the site, get redirected to the PDF I have set for the maintenance mode.

I have looked for the answer but all I see everywhere is the code I'm showing you above.

Examples:

Redirect to Maintenance Page

How to set maintenance mode for entire website with htaccess

.htaccess “Down For Maintenance” Page Redirect

Anton Silva
  • 11
  • 1
  • 1

2 Answers2

1

Try uncommenting the directives in your htaccess. The whole thing is commented out. None of it is going to be usable without directives. Any line that begings with a # is something that your server is going to ignore.

  • Hi, Martin! Thank you for the answer. Even though everything is commented out in the example, I deleted the "#" when testing the code. Sorry for the confusion. – Anton Silva Jan 08 '19 at 19:54
0

I couldn't really figure it out, but I found a workaround (note that I am using Wordpress):

  1. Duplicated index.php file and named it index2.php
  2. In Wordpress, under Settings < General y changed the "Website address" (note is not the Wordpress URL, only the website) to: http://example.ex/index2.php instead of http://example.ex/.
  3. In the .htaccess file I added a redirect sentence for index.php. This is how it ended up looking like:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RedirectMatch ^/$ /maintenance.html
</IfModule>

This allowed me to show a "maintenance" page to the regular user while still being able to see the whole site when going straight to: http://example.ex/index2.php

Anton Silva
  • 11
  • 1
  • 1