Apr
27
htaccess Deny Diractory Access During a Specific Time
April 27, 2008 |
If for some reason you would like to block access to files in a directory during a specific time of day, you can do so by adding the following code to an .htaccess file.
RewriteEngine On
# If the hour is 16 (4 PM)
RewriteCond %{TIME_HOUR} ^16$
# Then deny all access
RewriteRule ^.*$ - [F,L]
In the above example, if the hour is 16 (4 PM), the all access would be denied. You can also block multiple hour:
RewriteEngine On
# Multiple hour blocks
# If the hour is 4 PM or 5 PM or 8 AM
RewriteCond %{TIME_HOUR} ^16|17|08$
# Then deny all access
RewriteRule ^.*$ - [F,L]
Similar Posts
- Block people from Certain URL Using htaccess
- Block IPs Using htaccess
- Use htaccess with Site Maintenance Page
- Use htaccess to Deny Access Directory Listing
- Remove File Extension Using htaccess
- Use htaccess to Fake Different File Extension
- htaccess Remove the www From Domain URL
- Use htaccess to Deny Access to hidden Files
- Apache htaccess Prevent Users from Uploading and Executing Files
- Google Text Translation Using htaccess
- Deny Access to inc Files Using htaccess
- htaccess Conditional Loop Redirect
- htaccess Require the www For Domain URL
- htaccess Explicitly Define Default Index File
- Set Local Timezone Using htaccess
- htaccess Permanently redirect file or directory
- Force Files Like PDF Download using htaccess
- htaccess Limit the Number of Concurrent Visitors to your Website
- htaccess gzip for Faster Loading and Bandwidth Saving
- Create Custom Error Pages Using htaccess PHP
- Use htaccess for 404 Redirect
- Useful mod_rewrite Resources
Comments
1 Comment so far



































thanks for this, it really comes handy.