title: Rewrite rule with time conditions in .htaccess
body: <p>This is my first post on stackoverflow, as usually I managed to find an answer in the existing discussions, this time I did not :-)</p>
  
  <p>I need to create temporary url redirections based on day/time conditions for a few of my site pages. My site is hosted on OVH (Apache 2.4, mutualized) and I used Wordpress as CMS (4.9.1). </p>
  
  <p>I have read the Apache documentation about mod_rewrite, as well browsed different sources to do some trial/error testings, did not manage to get a piece of code to work in my <code>.htaccess</code> file (root www). </p>
  
  <p>I want to achieve the following: URL1 (<code>https://www.mysite.co/url1</code>) should be redirected to URL2 (<code>https://www.mysite.co/url2</code>) from Monday 5pm till Thursday 5pm. Then (outside this time window), redirection does not happen. </p>
  
  <p>I tried to implement some simple rewrite rules to already get URL1 to be redirected to URL2 when time > given date/hour, but did not work - see codes I tried: </p>
  
  <ul>
  <li><strong>Code 1:</strong></li>
  </ul>
  
  <p>/# Redirect URL1 to URL2 when TIME > Nov 30 2017, 6:15pm</p>
  
  <pre><code>RewriteEngine On
  
  RewriteCond %{TIME_YEAR}%{TIME_MON}%{TIME_DAY}%{TIME_HOUR}%{TIME_MIN} &gt;201711301815
  RewriteRule ^URL1$ /URL2? [L,R=301]
  </code></pre>
  
  <p><strong>- Code 2:</strong></p>
  
  <p>/# Redirect URL1 to URL2 when TIME > Nov 30 2017, 6:15pm</p>
  
  <pre><code>RewriteEngine On
  
  RewriteCond %{TIME_YEAR}%{TIME_MON}%{TIME_DAY}%{TIME_HOUR}%{TIME_MIN} &gt;201711301815
  RewriteCond %{REQUEST_URI} /URL1.*
  RewriteRule (.*) /URL2 [L,R=302,QSA]
  </code></pre>
  
  <p>I know I am doing sthg wrong, but can't figure out what/where on my own, so I'd be thankful if someone could help me out solve this silly issue!</p>
  
  <p>Am attaching a copy of my <a href="https://drive.google.com/open?id=1rAqITc_D3IhRIPwssuYes0PBIbr2sacc" rel="nofollow noreferrer"><code>.htaccess</code></a> in case helpful/anything to check there (I have removed all lines of codes referring to this matter). </p>
  
  <p>Thanks in advance!</p>
  
  <p><strong>EDIT (12/05/17) - Code 1 &amp; 2 with full URLs:</strong></p>
  
  <p><strong>- Code 1</strong></p>
  
  <pre><code>RewriteEngine On
  RewriteCond %{TIME_YEAR}%{TIME_MON}%{TIME_DAY}%{TIME_HOUR}%{TIME_MIN} &gt;201711301815
  RewriteRule ^commande-lundi$ /desole? [L,R=301]
  </code></pre>
  
  <p>With « full » URLs would be : </p>
  
  <pre><code>RewriteEngine On
  RewriteCond %{TIME_YEAR}%{TIME_MON}%{TIME_DAY}%{TIME_HOUR}%{TIME_MIN} &gt;201711301815
  RewriteRule ^https://mysite.co/commande-lundi$ /https://mysite.co/desole? [L,R=301]
  </code></pre>
  
  <p><strong>- Code 2</strong></p>
  
  <pre><code>RewriteEngine On
  RewriteCond %{TIME_YEAR}%{TIME_MON}%{TIME_DAY}%{TIME_HOUR}%{TIME_MIN} &gt;201711301815
  RewriteCond %{REQUEST_URI} /commande-lundi.*
  RewriteRule (.*) /desole [L,R=302,QSA]
  </code></pre>
  
  <p>With full URLs: </p>
  
  <pre><code>RewriteEngine On
  RewriteCond %{TIME_YEAR}%{TIME_MON}%{TIME_DAY}%{TIME_HOUR}%{TIME_MIN} &gt;201711301815
  RewriteCond %{REQUEST_URI} /https://mysite.co/commande-lundi.*
  RewriteRule (.*) /https://mysite.co/desole [L,R=302,QSA]
  </code></pre>