2

I have a specific folder for which I want to trigger a 503 response (maintenance). The rest of my website should be accessible.

can this be easily done in htaccess?

I browsed the web but can only find information on how to do it for the whole website.

ErrorDocument 503 /503.php
RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^123\.456\.789\.000
RewriteCond %{REQUEST_URI} !/503.php$ [NC]
RewriteCond %{REQUEST_URI} !\.(css|gif|ico|jpg|js|png|swf|txt)$
RewriteRule .* - [R=503,L]

PS: I also tried to find a more general tutorial on htaccess and this type of stuff so I can learn the basics and figure out things myself. But all I found was snippets and snippets and more snippets. Any suggestions?

Kolja
  • 860
  • 4
  • 10
  • 30

1 Answers1

0

You need to just place above code in /folder/.htaccess where you want to show 503 custom page. Otherwise your code looks fine. Just make sure /503.php exists.

anubhava
  • 761,203
  • 64
  • 569
  • 643
  • Thanks, this worked except that it does not show my ErrorDocument. Somehow the server displays a default 503 page instead. I am running Apache on CentOS, pretty standard setup I believe. What can I do? – Kolja Oct 10 '14 at 12:01
  • I tested it again it works on my Apache. Just make sure `/503.php` exists in root not in current folder. For keeping itside folder use `ErrorDocument 503 /folder/503.php` – anubhava Oct 10 '14 at 12:06
  • For me it doesn't work. I think something is wrong with the settings. I will contact my provider. Thanks for the answer, at least the 503 http response header is being sent like this! – Kolja Oct 10 '14 at 12:20