Jump to content

Recommended Posts

Posted

If this is a one-time thing, the easiest way to do it would be to just add the following line of code to your homepage in the <head> section at 5 and remove it at 9.

 

<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.yourdomain.com/index.html">

(replace http://www.yourdomain.com/index.html with where you want users to be redirected to)

 

If it is a daily thing, some more coding will be required.

Posted

You can do this with htaccess. There's got to be a better regex for the time span, but this is a rough way of doing it:

 

RewriteEngine On
RewriteCond %{TIME_HOUR} ^17|18|19|20|21|22|23|00|01|02|03|04|05|06|07|08|09$
RewriteRule ^$|^index\.html$ /time-restricted.html [R=302,L]

 

 

A better way to write the time (untested):

 

RewriteEngine On
RewriteCond %{TIME_HOUR}%{TIME_MIN} >1700
RewriteCond %{TIME_HOUR}%{TIME_MIN} <0900
RewriteRule ^$|^index\.html$ /time-restricted.html [R=302,L]

 

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...