开发者

Htaccess redirect from 12am to 6pm on a certain date

I would like to know how I can redirect to a certain page (during maintenance) at a certain date between 开发者_C百科12am and 6pm for example.

thanks! Jasper


Maybe a cron job to create/move the .htaccess file and then a second to delete it?


You can program rewrite rules in .htaccess to redirect trafic based on time or date. Look at the 'date and time' variables that you can use on the rewrite_cond documentation

You can compound the different TIME_ variables to get to a number that you can compare.

For example, to redirect trafic between midnight (00) and 4am (04) every Tuesday (02), you could use

RewriteCond %{TIME_WDAY}%{TIME_HOUR} > 0200    # IF it's after Tuesday 00
RewriteCond %{TIME_WDAY}%{TIME_HOUR} < 0204    # AND it's before Tuesday 04
RewriteRule ^$ /maintenance.html [R=302,L]     # THEN redirect to maintenance page

You can find more examples here and here

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜