Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect on specific date/time with htaccess

Is it possible to redirect on specific date/time?

For Example ... what would be htaccess code for redirecting website on 30th July, 10 AM?

Update

Here is my current htaccess code, where my requirement (see above) will be included

RewriteEngine On 
RewriteBase / 

RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] 
RewriteRule ^(.*)$ http://%1/$1 [R=301,L] 

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.+)/$ /$1 [R,L] 

RewriteCond $1 !^(index\.php) 
RewriteCond %{REQUEST_URI} !(\.png|\.jpg)$ 
RewriteRule ^(.*)$ index.php?l=$1 [L] 

RewriteCond %{THE_REQUEST} ^GET\ /(.+)\.html [NC] 
RewriteRule ^ /%1? [R=301,L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^\.]+)$ $1.html [NC,L]
like image 534
johnny456 Avatar asked Jan 27 '23 17:01

johnny456


1 Answers

You can use this rule (you need to enable mod_rewrite)

RewriteEngine On

RewriteCond %{TIME} >=20180730100000
RewriteCond %{TIME} <20180730110000
RewriteRule ^ /other_page [R,L]

It will (temporarily) redirect to /other_page between 10:00:00 AM and 10:59:59 AM (only on July 30)

Explanation: %{TIME} value format is yyyymmddhhiiss where:

  • yyyy = year (4 digits)
  • mm = month (2 digits)
  • dd = day (2 digits)
  • hh = hour (2 digits)
  • ii = minutes (2 digits)
  • ss = seconds (2 digits)
like image 99
Justin Iurman Avatar answered Feb 27 '23 07:02

Justin Iurman