I want to redirect all the traffic at location ~ ^/ using Nginx. I tried using $msec in nginx if condition but it is returning error unknown directive “if($msec)”. I want to have start_date, start_time, end_date and end_time constrains between which i want to redirect all of my traffic to a different page.
I have tried using if condition in a location block
location ~ ^/ {
if($msec > $start_dateT$start_time && $msec < $start_dateT$start_time) {
rewrite ^(.*)$ https://www.example.com/maintenance/?redirect_url=$request_uri break;
}
}
New contributor
Divyansh Sharma is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.