V
V
viktorspr2015-08-10 10:11:33
htaccess
viktorspr, 2015-08-10 10:11:33

Need help with .htaccess on RewriteRule. How to add an exception?

Already worn out, there is a stub "the site is temporarily down, come back later ..." if the file unavailable/unavailable.php is located at the address, it works. In any other cases, returns index.php.
.htaccess at the root is like this. The problem is that it cuts everything in the /unavailable js directory, and css c jpg, gives only pure unavailable.php, how can I put all these extensions into an exception?

RewriteEngine On
RewriteBase /

RewriteCond %{DOCUMENT_ROOT}/unavailable/unavailable.php -f
RewriteRule ^.* unavailable/unavailable.php [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
heartdevil, 2015-08-10
@viktorspr

Hello.
Try like this

RewriteEngine On
RewriteBase /

RewriteCond %{DOCUMENT_ROOT}/unavailable/unavailable.php -f
RewriteCond %{REQUEST_URI} !^/unavailable 
RewriteRule ^.*$ unavailable/unavailable.php [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

I've also seen people throw 503 errors and redirect to a stub.

V
viktorspr, 2015-08-10
@viktorspr

Thank you earned!
As for the error given in the title, it is, the code is in the stub

<?php
header('HTTP/1.0 503 Service Unavailable');
header('Retry-After: 3600');
?>

Now we want to make some kind of landing on the stub, I think it will work out well...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question