...

View Full Version : Redirect



mpacaon
08-15-2008, 05:17 AM
Hi!

I'd like to ask how to redirect from one PHP to another PHP provided that they are in a different directory. I already found a code that can redirect from one PHP page to another PHP page. However, that is only in the same directly. The code is shown below:


<?php
/* Redirect to a different page in the current directory that was requested */
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = 'anotherpage.php';
header("Location: http://$host$uri/$extra");
exit;
?>

I'd like to know how to redirect to another page in an upper directory.

----> index.php
----> idliketogohere.php
[subfolder]
--> currentpage.php
--> anotherpage.php

Len Whistler
08-15-2008, 05:55 AM
Use the complete URL.


header("Location: http://www.mysite.php/folder/folder/file.php");



------------

mpacaon
08-15-2008, 06:26 AM
I discovered the answer. Here:


$host = $_SERVER['HTTP_HOST'];
$folder = "lotcheckeditor";

header("Location: http://$host/$folder/pages/sorry.html");



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum