How to quickly deactivate a vhost/domain with an .htaccess file
Sometimes you need to put quickly a holder page or cancel a vhost/domain for various reasons.
The presented solution redirects the requests to chosen extensions to an txt file.
The txt file should be added in the document root folder (www, public_html, html, htdocs, httpdocs, httpsdocs etc) and this is what the visitors will see when they access the deactivated site/domain .
Add the following in your .htaccess file. If it doesn't exist create it.
RedirectMatch temporary /.*\.(html?|php5?|jpe?g|gif|png|pdf|doc|xls)$ /message.txt
ErrorDocument 404 /message.txt
Options -Indexes
Note:
These rules won't exclude files whose extensions are not listed.
Therefore make sure you list all the file extensions between the brackets.
New extensions should be separated by a pipe ("|" sign)
I recommend adding ErrorDocument just in case so new users will have an idea if a file is missing.
Options -Indexes is to stop Apache from listing directories which don't have an index.html file.

0 comments:
Post a Comment