Forum Moderators: coopster
http*//www.foo.com/dir.php?foo1/foo2/foo3/foo4/
go to
http*//www.foo.com/foo4/
and everything under foo4/ would also redirect to the new location. I don’t think it can be done in .htaccess because the folders are not really there to contain the .htaccess file because they been re-written from something like:
http*//www.foo.com/dir.php?a=foo1&b=foo2&c=foo3
So is there a way in php to write it based on the url, maybe:
<?
if ($_SERVER['REQUEST_URI']) = http*//www.foo.com/foo1/foo2/foo3/foo4/){
header("HTTP/1.1 301 Moved Permanently");
header("Location: http*//www.foo.com/foo4/");
exit();
?>
Thanks
<?
if ($_SERVER['REQUEST_URI']) = http*//www.foo.com/foo1/foo2/foo3/foo4/){
header("HTTP/1.1 301 Moved Permanently");
header("Location: http*//www.foo.com/foo4/");
exit();
?>
yeah you can get away with somthing like that... check out eregi using regex.
if(eregi("http:\/\/([a-zA-Z0-9\.]+).com\/([a-zA-Z0-9\/]+)\/foo4",$_SERVER['REQUEST_URI'],$plist))
{
// do stuff here/redirect headers in here
}
$plist becomes an array you can do a foreach statement and see what elements print/contain what
foreach($plist as $k=>$l)
{
echo "Position: $k contains: $l<br>";
}