Reputation: 41
This is my code:
Header set Cache-Control "max-age=0, private, no-store, no-cache, must-revalidate"
RewriteEngine on
RewriteCond %{REQUEST_URI} !(admin)
RewriteRule !maintenance\.php$ /maintenance.php [R=301,L]
I want to redirect all traffic on the site to maintenance.php except for any requests for files in /admin. I've tried so many combinations that never work. It always redirects no matter what. I can't figure out what could be causing this.
UPDATE: I figured something out. If I comment out the .htaccess in the admin folder, Ben's code works. Here's the code there:
AuthType Basic
AuthName "Restricted area"
AuthUserFile "/home1/user/.htpasswds/public_html/example/admin/passwd"
require valid-user
What can I do to this .htaccess file to allow it to work?
Upvotes: 0
Views: 46
Reputation: 105
why don't you use this line DirectoryIndex maintenance.php
in .htaccess in order to redirect to this page . ones your site is ready you can remove maintenance mode by commenting the above line
Upvotes: 0
Reputation: 5129
Don't use permanent redirect R=301
in this purpose, you site is not maintenance permanently. Use temporary redirect R=302
only, otherwise your users will always see maintenance page even if you remove this rule, because R=301
is cached by browser.
%{REQUEST_URI}
starts with /
.
RewriteCond %{REQUEST_URI} !^/admin
RewriteCond %{REQUEST_URI} !^/maintenance.php$
RewriteRule ^ /maintenance.php [R=302,L]
Upvotes: 1