How would I rewrite all requests to maintenance.php, if it exists, except images, and except an IP white list.
If maintenance.php does not exist it should rewrite to a bootstrap (index.php) if the requested file does not exist.
If maintenance.php does exist and the IP is in the white list, then it should rewrite to a bootstrap (index.php) if the requested file does not exist.
I have tried many variations of the following:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{DOCUMENT_ROOT}/maintenance.php -f
RewriteCond %{REQUEST_FILENAME} !\.(jpg|png|gif)$
RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123$
RewriteCond %{REMOTE_ADDR} !^111\.111\.111\.111$
RewriteRule . maintenance.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
</IfModule>
I would do it in reverse. Rewrite to the bootstrap if the maintenance page doesn’t exist or the IP is valid.
So, basically it will run index.php IF:
We could expand this out using propositional logic, but why bother…