Search code examples
apache.htaccesshttp-redirectmod-rewriteurl-rewriting

How to Show a 503 Error for a Specific URL on a Website Using .htaccess


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]

Solution

  • 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