redirect using htaccess based on date in php
Thanks.
You'll have to test for the date, in your PHP script ; and redirect, using the header()
function :
if ($_GET['dt'] <= date('Y-m-d')) {
// Redirect to your other page
header('Location: http://www.yoursite.com/page-not-found.php');
exit();
}
Note : before doing this test, it might be interesting to :
- Ensure that
$_GET['dt']
exists, usingisset()
- Verify if it contains something that's a valid date
Why does it need to be via .htaccess? Seems like this logic is better put in the script itself:
if ($date < $somedate) {
header('HTTP/1.1 302 Found');
header('Location: http://www.example.com/error.php');
exit;
}
精彩评论