.htaccess how to show 503 for a specific URL on a website

Viewed 411

I want to show 503 error on a specific URL of my website. This should only apply to that specific URL and other pages should load fine. So far I've tried the following with no luck. Any help is appreciated. Thanks.

ErrorDocument 503 "Our website is temporarily closed for scheduled maintenance."
RewriteEngine On
RewriteCond %{REMOTE_ADDR} !http://example.com/myspeicifcpage$
RewriteRule .* - [R=503,L]
2 Answers

For your mentioned URLs you could try following, this will look for specific urls like http://localhost:80/ or http://localhost:80/a or http://localhost:80/b.

ErrorDocument 503 /league.php
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/?$ [OR]
RewriteCond %{REQUEST_URI} ^/(a|b)/?$ [NC]
RewriteRule .* - [R=503,L]


OR In case you want to get 503 for any page for domain name example.com then you could try following.

ErrorDocument 503 /league.php
RewriteEngine On
RewriteCond %{HTTP_HOST} example\.com [NC]
RewriteRule .* - [R=503,L]

You can use this :

ErrorDocument 503 "Our website is temporarily closed for schedule maintenance"
Redirect 503 /specificPage

This will print the error text on /specificPage if it is accessed.

You can also markup the error message using html tags

ErrorDocument 503 "<b>Our website is temporarily closed for schedule maintenance.</b>"
Redirect 503 /specificPage
Related