Simple PHP error, wtf?

Status
Not open for further replies.

Brandon

Former Senior Account Rep
Community Support
Messages
19,181
Reaction score
28
Points
48
PHP:
if (!file_exists('config.php')) {
 header("Location: install/install.php");
}

it aint working and config.php isnt there, i am using apache 2.2.4 and php 5.2.1

SIMPLEST thing ever and it isnt working, wtf...
 

Cubeform

New Member
Messages
339
Reaction score
0
Points
0
PHP header() redirects won't work with relative URLs; they will only work with the whole thing (i.e. with the "http://yourwebsite.com/"). Here's how you would do this:
PHP:
<?php
$host  = $_SERVER['HTTP_HOST'];
$uri  = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
header("Location: http://$host$uri/install/install.php");
exit;
?>

(I got this from a PHP manual page and modified it slightly)
 
Last edited:

Brandon

Former Senior Account Rep
Community Support
Messages
19,181
Reaction score
28
Points
48
PHP header() redirects won't work with relative URLs; they will only work with the whole thing (i.e. with the "http://yourwebsite.com/"). Here's how you would do this:
PHP:
<?php
$host  = $_SERVER['HTTP_HOST'];
$uri  = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
header("Location: http://$host$uri/install/install.php");
exit;
?>

(I got this from a PHP manual page and modified it slightly)

They do for me, and anything I try dosnt wirk, echo, die, i have tried it all:eek4:

It isnt the header, thats all i know.
 

dharmil

New Member
Messages
1,656
Reaction score
0
Points
0
you could try

PHP:
<?php
function goToUrl($ref, $url){
    if ($url == ''){
        $url = 'index.php';
    }
    header ( "refresh: $ref; url=".str_replace('&amp;', '&', $url) ) ;
}
?>
i made it to redirect and it works fine

or try:
PHP:
<?php
header('Location: '.str_replace('&amp;', '&', 'http://www.example.com/?do=1&go'));
?>
 
Last edited:

Brandon

Former Senior Account Rep
Community Support
Messages
19,181
Reaction score
28
Points
48
The redirect is fine

its that file_exists thing
 

Bryon

I Fix Things
Messages
8,149
Reaction score
101
Points
48
Do you get an error at all, or does it just not return true/false like it "should?"
 

Brandon

Former Senior Account Rep
Community Support
Messages
19,181
Reaction score
28
Points
48
****, thats the problem, i was editing a read-only file and it wasnt saving, it works now:p
 
Last edited:
Status
Not open for further replies.
Top