Bonjour,
je cherche une solution pour que mon site ne soit accessible que du 2 au 5 Août et que le reste du temps il ramène sur une page de maintenance. Je pensais donc modifier mon fichier .htaccess, voilà où j'en suis :

Options +FollowSymlinks
RewriteEngine on
RewriteBase /

DirectoryIndex accueil.php secret4.php enigma1.php secret1.php open.php codefin.php secret5.php

RewriteCond %{REQUEST_URI} !/notime.php$
RewriteCond %{REMOTE_HOST} !^888\.888\.888\.888
RewriteRule $ /notime.php [R=302,L]

Le problème c'est que je ne vois pas comment mettre une condition au niveau de la date.
En espérant que vous puissiez m'aider.

2 réponses


maxslayer44
Réponse acceptée

Bonjour,

J'ai fait quelques recherches (cf ce http://www.webforgers.net/code-library/date-and-time-content-delivery.php si tu as besoin de plus d'infos) pour essayer de te répondre, tu peux essayer quelque chose comme ça :

Options +FollowSymlinks
RewriteEngine on
RewriteBase /

DirectoryIndex accueil.php secret4.php enigma1.php secret1.php open.php codefin.php secret5.php

RewriteCond %{REQUEST_URI} !/notime.php$
RewriteCond %{REMOTE_HOST} !^888\.888\.888\.888 # Normalement tu n'auras jamais une IP comme celle-ci
RewriteCond %{TIME_MON} ^08 # En aout
RewriteCond %{TIME_DAY} >01 [OR] # Du 2
RewriteCond %{TIME_DAY} <06 [OR] # Au 5

RewriteRule $ /notime.php [R=302,L] # Tu accède à cette page

Je n'ai pas testé, tiens-nous au courant de si ça fait l'affaire ou pas ^^

Bonne journée

Après quelques corrections voilà le script fonctionnel :

Options +FollowSymlinks
RewriteEngine on
RewriteBase /

DirectoryIndex accueil.php secret4.php enigma1.php secret1.php open.php codefin.php secret5.php

RewriteCond %{TIME_MON} =08
RewriteCond %{TIME_DAY} <02 [OR]
RewriteCond %{TIME_DAY} >05
RewriteCond %{REQUEST_URI} !/notime.php$
RewriteCond %{REMOTE_HOST} !^888\.888\.888\.888
RewriteRule $ /notime.php [R=302,L] 

RewriteCond %{TIME_MON} !=08
RewriteCond %{REQUEST_URI} !/notime.php$
RewriteCond %{REMOTE_HOST} !^888\.888\.888\.888
RewriteRule $ /notime.php [R=302,L]

Merci :)