Security and SSL

Show a temporary notice by replacing the index file

Reviewed on 1 min read seguridad web control de acceso

To temporarily show a notice when people visit the home page, you can replace the website's index file.

First keep a copy of the original index.php or index.html outside all public directories, where it cannot be downloaded over the web. Then create a new index with the notice you want to show.

This method does not block access: visitors can still request static files, routes that do not go through the index, APIs or other PHP scripts. Nor does it contain an intrusion or stop scheduled tasks or outgoing email.

If you really need to restrict a website during maintenance work, use HTTP authentication or access rules and check the result. To revert the notice, delete the temporary index and restore the original's name and permissions.

Choose the method for your goal

If you only want a notice on the home page, check which file actually serves /: the server may give priority to index.html, or the application may use its own rules. Keep the original without leaving a public index.php.bak, which could display code as text.

For general temporary unavailability, use a maintenance mode that returns HTTP 503 and check its scope. An empty page with a 200 response may be treated as the website's normal content. If you need to prevent access to documents, use username and password protection or a suitable restriction and test direct URLs too.

You may also find useful

Something wrong or out of date? Tell us and we will review it.