Let's say I have a directory I want to restrict access that way, so that users can access the directory only on like 6am to 6pm. I know how to do this by using PHP (using time()%86400
). But can I do it entirely using Apache's builtin functions (.htaccess or server apache2.conf) or other mods?
You can deny access to certain directories depending on the time by placing the following code in your .htaccess file in the directory you want to control:
The hours are based on 24 hours in a day (0-23) and each hour you wish to deny access should be seperated with a “|”.
In the above example, nobody could access the directory from 1-3pm.