user3476977
user3476977

Reputation: 33

Setting up an “under maintenance” template with Apache .htaccess

I would like to know how I can install an under maintenance template to my site. It contains this files and folder:

I have used the code below in my .htaccess file to redirect to the index.html, but it only shows the html content.

RewriteEngine on
RewriteCond %{REQUEST_URI} !/index.html$
RewriteCond %{REMOTE_ADDR} !^123.123.123.123
RewriteRule $ /index.html [R=302,L]

How can I pull the images and CSS I have in the other folders?

Upvotes: 0

Views: 147

Answers (1)

Giacomo1968
Giacomo1968

Reputation: 26066

Try this instead:

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !^/maintenance\.html$
RewriteCond %{REMOTE_ADDR} !=123.123.123.123
RewriteRule ^(images|tools)($|/) - [L]
RewriteRule ^(.*)$ /maintenance.html [NC,L,R=302]

This will ignore the images & tools directory but redirect all content to /maintenance.html. I also adjusted the format of the REQUEST_URI URL as well as the REMOTE_ADDR check.

Upvotes: 2

Related Questions