Question

These are the codes i have added in and we get a The page isn't redirecting properly. Firefox has detected that the server is redirecting the request for this address in a way that will never complete. This problem can sometimes be caused by disabling or refusing to accept cookies.

<? 
 ob_start(); session_start(); ob_end_clean(); 

$title              = "Antalya Apartments For Sale, Turkey Property";
$slink              = "antalya_apartment.php"; 
$default_bolge      = 4; 
$sql_emlak_turleri  = " ( emlakkayit.eturu='1' ) "; 
$canonical          = "antalya_apartment.php"; 

include "ust.php";

//bolgelerden birisi secilmis ise filtreleme yapilir
if($_GET[bid]>0) { $default_bolge = $_GET[bid]; } 

$sql_ek     = " AND emlakkayit.ilce='".$default_bolge."' "; 

//bolgeler
$sql = "SELECT
        bolge.id,
        bolge.bolge,
        count(emlakkayit.id)
    FROM
        bolge 
        LEFT JOIN emlakkayit ON emlakkayit.ilce=bolge.id 
    WHERE ".$sql_emlak_turleri." 
    GROUP BY bolge.id 
    ORDER BY bolge.bolge ASC " ;    
//$sql = "SELECT id,bolge FROM bolge ORDER BY bolge ASC " ; 
$DB->sorgula($sql); $syc=0;  
while($bolgeler = $DB->satirgetir($DB->sorgu_id))
{
$syc++;
$blg[$syc][id]      = $bolgeler[0];
$blg[$syc][bolge]   = $bolgeler[1];
$blg[$syc][ks]      = $bolgeler[2];
}
$DB->kapat($DB->sorgu_id);

$sql = "SELECT
        bolge.id,
        bolge.bolge,
        count(emlakkayit.id)
    FROM
        bolge 
        LEFT JOIN emlakkayit ON emlakkayit.ilce=bolge.id 
    WHERE 
        ".$sql_emlak_turleri." ".$sql_ek."
    GROUP BY bolge.id 
    ORDER BY bolge.bolge DESC " ;   
$DB->sorgula($sql); $sayac=0;  
while($bolgeler = $DB->satirgetir($DB->sorgu_id))
{
$sayac++;
$bolgeler_dizi[$sayac][id]      = $bolgeler[0];
$bolgeler_dizi[$sayac][bolge]   = $bolgeler[1];
$bolgeler_dizi[$sayac][ks]      = $bolgeler[2];
$toplam_kayit[$bolgeler[0]]     = $bolgeler[2];
if( $default_bolge==$bolgeler[0] ) $iste_bolgemiz = $bolgeler[1] ;
}

if ($sayac == 0) { ob_end_clean(); header('Location: http://www.turkish-property-world.com/antalya_apartment.php'); die; }

$DB->kapat($DB->sorgu_id);
//bolgeler diziye atildi

//paging on hazirlik
$goruntu_sayisi = 5 ;
$toplam_kayit_s = $toplam_kayit[$default_bolge] ;
$off            = "";
$paging_sayfa_sayisi = ceil($toplam_kayit_s / $goruntu_sayisi) ;
if($paging<=0) { $baslangic = 0 ; } else { $baslangic = $paging*$goruntu_sayisi ; }
?>
Était-ce utile?

La solution

404 from script

In your script I would simply check the count of products (before outputting anything), and if there are zero products execute ...

header("HTTP/1.0 404 Not Found");
die;

or in case your page uses FastCGI:

header("Status: 404 Not Found");
die;

Recirect to other page

Since the point came up that showing a 404 might mess up SEO results for your page, you might consider redirecting to your start-page (or something similar).

In your antalya_apartment.php either with a header redirect, ...

header('Location: http://www.turkish-property-world.com/antalya_apartment.php');
die;

... or optionally you could also just choose to alter your data (e.g. change your bid and page vars).

Logic for specific pages

You could put following right at the top of your php script:

if ($_GET['bid']==4 && $_GET['page']==9)
{
    header("HTTP/1.0 404 Not Found");
    die;
}

In your case to do specific redirects:

<? 

// Right at the top do your checking/redirecting/...
if ($_GET['bid']==4 && $_GET['page']==9)
{
    header("HTTP/1.0 404 Not Found");
    die;
}

ob_start();  
session_start();

$title              = "Antalya Apartments For Sale, Turkey Property";
$slink              = "antalya_apartment.php"; 
$default_bolge      = 4; 
$sql_emlak_turleri  = " ( emlakkayit.eturu='1' ) "; 
$canonical          = "antalya_apartment.php"; 

include "ust.php";

// ...

Logic to get the product count and redirect whenever there is no result

If you put this right after your while loop, it should redirect every time there are NO products available.

// ...
$sql = "SELECT
        bolge.id,
        bolge.bolge,
        count(emlakkayit.id)
    FROM
        bolge 
        LEFT JOIN emlakkayit ON emlakkayit.ilce=bolge.id 
    WHERE 
        ".$sql_emlak_turleri." ".$sql_ek."
    GROUP BY bolge.id 
    ORDER BY bolge.bolge DESC " ;   
$DB->sorgula($sql); $sayac=0;  
while($bolgeler = $DB->satirgetir($DB->sorgu_id))
{
$sayac++;
$bolgeler_dizi[$sayac][id]      = $bolgeler[0];
$bolgeler_dizi[$sayac][bolge]   = $bolgeler[1];
$bolgeler_dizi[$sayac][ks]      = $bolgeler[2];
$toplam_kayit[$bolgeler[0]]     = $bolgeler[2];
if( $default_bolge==$bolgeler[0] ) $iste_bolgemiz = $bolgeler[1] ;
}

//////////////////////////////////////////////////
if ($sayac == 0)
{
    header('Location: http://www.turkish-property-world.com/antalya_apartment.php');
    die;
}
//////////////////////////////////////////////////

$DB->kapat($DB->sorgu_id);
//bolgeler diziye atildi

//paging on hazirlik
$goruntu_sayisi = 5 ;
$toplam_kayit_s = $toplam_kayit[$default_bolge] ;
$off            = "";
$paging_sayfa_sayisi = ceil($toplam_kayit_s / $goruntu_sayisi) ;
if($paging<=0) { $baslangic = 0 ; } else { $baslangic = $paging*$goruntu_sayisi ; }
?>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top