October 22, 2020, 11:26:42 pm
News: If someone gives you assistance give them a Good Star
Pages: [1]   Go Down
Author Topic: Lost Topic Title  (Read 585 times)
Slowhand
Supporters
*

Stars: +0/-0
Offline Offline

Gender: Male
Awards:
Topic Necromancer
Posts: 4668


I code C#!


WWW
« on: October 05, 2004, 01:42:49 pm »

Hi,

I have this HTML code to redirect to another page:

Code:
<meta http-equiv="Refresh" content="4;url=http://www.mysite.com/index.php">

Now I want to change that the static URL into a variable one, but I'm having some problems with that.

How can I change it to something like
Code:
<<meta http-equiv="Refresh" content="4;url=" $myURL ">"

Cheers,

CJ
Logged


Chris
Founders
*

Stars: +0/-0
Offline Offline

Posts: 3312


MIA


« Reply #1 on: October 05, 2004, 01:49:27 pm »

:?:

Code:
<?php
$myURL = 'cheese.html';
?>
<meta http-equiv="Refresh" content="4;url=<?php echo $myURL; ?>">

:?:
Logged

When the Bogeyman goes to sleep every night, nothing happens.

CornedBee
Ancient Poster
*

Stars: +0/-0
Offline Offline

Gender: Male
Posts: 5258


WWW
« Reply #2 on: October 05, 2004, 02:15:07 pm »

I believe the URL must be absolute, but I'm not sure. I personally don't like meta-based redirects.
Logged

All the buzzt
CornedBee

"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond

"This is how Liberty dies - with thunderous applause."
Senator Padmé Amidala - Revenge of the Sith

Slowhand
Supporters
*

Stars: +0/-0
Offline Offline

Gender: Male
Awards:
Topic Necromancer
Posts: 4668


I code C#!


WWW
« Reply #3 on: October 05, 2004, 02:17:25 pm »

Quote
I believe the URL must be absolute, but I'm not sure. I personally don't like meta-based redirects.
What's another way to do it, then?
Logged


CornedBee
Ancient Poster
*

Stars: +0/-0
Offline Offline

Gender: Male
Posts: 5258


WWW
« Reply #4 on: October 05, 2004, 02:26:32 pm »

Uh...

Well, you could serve a real redirect using a 3xx code and a Location header. OR you could serve the Redirect header as a real header. It's easy from within PHP.

Still doesn't change the fact that you need an absolute URL, though. Here's the redirect function I use:
Code:
// Redirects to the relative URL $rel.
function redirect($rel) {
$this->log("Redirecting to $rel.");
// These redirects are for display after processing-only pages.
// So make sure HTTP/1.1 (and higher) clients get a 303 (See Also).
// That code doesn't exist in 1.0, so send the default 302. (Moved Temp).
$prt = $_SERVER['SERVER_PROTOCOL'];
$http_minor = intval(substr($prt, 6));
if($http_minor >= 1) {
  header("$prt 303 See Also");
}
// Guess the scheme according to the port. If the port is listed in
// http_ports, then set scheme to http, otherwise assume a secure
// connection.
$http_ports = array(80, 8080);
$port = $_SERVER['SERVER_PORT'];
if(in_array($port, $http_ports)) {
  $scheme = 'http';
} else {
  $scheme = 'https';
}
header('Location: '.$scheme.'://'.$_SERVER['HTTP_HOST'].
  dirname($_SERVER['PHP_SELF']).$rel);
}
« Last Edit: October 05, 2004, 02:27:16 pm by CornedBee » Logged

All the buzzt
CornedBee

"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond

"This is how Liberty dies - with thunderous applause."
Senator Padmé Amidala - Revenge of the Sith

Pages: [1]   Go Up
Print
 
Jump to: