vkGunasekaran
vkGunasekaran

Reputation: 6814

how to redirect in php using htaccess

I need to redirect a page like www.someone.com/2011/03/05 to sample.php?dt=2011/03/05 using htaccess and php, Thanks.

Upvotes: 0

Views: 342

Answers (3)

Tobias Schittkowski
Tobias Schittkowski

Reputation: 2251

You can use mod_rewrite if you have an Apache webserver and define the rules in your .htaccess.

See for example: http://corz.org/serv/tricks/htaccess2.php

Upvotes: 0

hsz
hsz

Reputation: 152294

RewriteEngine on
RewriteRule ^(\d{4}\/\d{2}\/\d{2})/?$ sample.php?dt=$1 [L]

Upvotes: 2

Pablo Santa Cruz
Pablo Santa Cruz

Reputation: 181460

If you have PHP you don't need .htaccess:

Just place this on your PHP file:

<?php
header("Location: http://www.someone.com/2011/03/05");
?>

Upvotes: 0

Related Questions