Seite 1 von 1

php Header Umleitung funzt nicht im IE [ERLEDIGT]

Verfasst: 21.05.2010, 11:26
von Azubi
Huhu, die Header Umleitung funktioniert im Firefox,Chrome und co aber nicht im IE 7,8.

"Die Seite konnte nicht angezeigt werden" Meldung erhalte ich nur

Vielleicht Jemand eine Idee?

Code: Alles auswählen

<?php

$SiteNameURL = $_SERVER&#91;'HTTP_HOST'&#93;;


switch &#40;strtolower&#40;$SiteNameURL&#41;&#41; &#123;

case "http&#58;//www.woy.ch"&#58; //MUST BE LOWER CASE
/*	
	if&#40;isset&#40;$_COOKIE&#91;'Sprache'&#93;&#41;&#41; &#123;
		header &#40;"location&#58; ".$_COOKIE&#91;'Sprache'&#93;&#41;;
	&#125;break;
*/		
		header&#40;"HTTP/1.1 301 Moved Permanently"&#41;; 
		header &#40;'location&#58;http&#58;//de.woy.ch'&#41;;die&#40;&#41;;

            break;
case "www.woy.ch"&#58; //MUST BE LOWER CASE

/*	
	if&#40;isset&#40;$_COOKIE&#91;'Sprache'&#93;&#41;&#41; &#123;
		header &#40;"location&#58; ".$_COOKIE&#91;'Sprache'&#93;&#41;;
	&#125;break;
*/
		  header&#40;"HTTP/1.1 301 Moved Permanently"&#41;; 	
		  header &#40;'location&#58;http&#58;//de.woy.ch'&#41;;die&#40;&#41;;

          break;
case "woy.ch"&#58; //MUST BE LOWER CASE

/*	
	if&#40;isset&#40;$_COOKIE&#91;'Sprache'&#93;&#41;&#41; &#123;
		header &#40;"location&#58; ".$_COOKIE&#91;'Sprache'&#93;&#41;;
	&#125;break;
*/			header&#40;"HTTP/1.1 301 Moved Permanently"&#41;; 
			header &#40;'location&#58;http&#58;//de.woy.ch'&#41;;die&#40;&#41;;

            break;                        
            
&#125;

if&#40;!isset&#40;$_COOKIE&#91;'Sprache'&#93;&#41;&#41;
&#123;
$sprache = $_SERVER&#91;"HTTP_ACCEPT_LANGUAGE"&#93;;
$sprache = explode &#40;',',$sprache&#41;;

switch&#40;$sprache&#91;0&#93;&#41; &#123;

case 'de-DE'&#58; 

if &#40;stristr&#40;$sprache&#91;0&#93;,'US'&#41;&#41;&#123;
    $weiterleitung = 'http&#58;//en.woy.ch';break;
&#125;

if &#40;stristr&#40;$sprache&#91;0&#93;,'ES'&#41;&#41;&#123;
    $weiterleitung = 'http&#58;//es.woy.ch';break;
&#125;
$weiterleitung = 'http&#58;//de.woy.ch';break;


case 'en-US'&#58; 

if &#40;stristr&#40;$sprache&#91;0&#93;,'DE'&#41;&#41;&#123;
    $weiterleitung = 'http&#58;//de.woy.ch';break;
&#125;

if &#40;stristr&#40;$sprache&#91;0&#93;,'ES'&#41;&#41;&#123;
    $weiterleitung = 'http&#58;//es.woy.ch';break;
&#125;

$weiterleitung = 'http&#58;//en.woy.ch';break;

case 'es-ES'&#58; 

if &#40;stristr&#40;$sprache&#91;0&#93;,'DE'&#41;&#41;&#123;
    $weiterleitung = 'http&#58;//de.woy.ch';break;
&#125;

if &#40;stristr&#40;$sprache&#91;0&#93;,'EN'&#41;&#41;&#123;
    $weiterleitung = 'http&#58;//en.woy.ch';break;
&#125;
	$weiterleitung = 'http&#58;//es.woy.ch';break;
&#125;

setcookie&#40;"Sprache", $weiterleitung&#41;;
header&#40;"HTTP/1.1 301 Moved Permanently"&#41;; 
header &#40;'location&#58;'.$weiterleitung&#41;;die&#40;&#41;;

&#125;


if &#40;defined&#40;'E_DEPRECATED'&#41;&#41; &#123;
	error_reporting&#40;E_ALL ^ E_NOTICE ^ E_DEPRECATED&#41;;
&#125; else &#123;
	error_reporting&#40;E_ALL ^ E_NOTICE&#41;;
&#125;


// ******************
// Constants defined
// ******************

define&#40;'PATH_thisScript',str_replace&#40;'//','/', str_replace&#40;'\\','/', &#40;PHP_SAPI=='cgi'||PHP_SAPI=='isapi' ||PHP_SAPI=='cgi-fcgi'&#41;&&&#40;$_SERVER&#91;'ORIG_PATH_TRANSLATED'&#93;?$_SERVER&#91;'ORIG_PATH_TRANSLATED'&#93;&#58;$_SERVER&#91;'PATH_TRANSLATED'&#93;&#41;? &#40;$_SERVER&#91;'ORIG_PATH_TRANSLATED'&#93;?$_SERVER&#91;'ORIG_PATH_TRANSLATED'&#93;&#58;$_SERVER&#91;'PATH_TRANSLATED'&#93;&#41;&#58;&#40;$_SERVER&#91;'ORIG_SCRIPT_FILENAME'&#93;?$_SERVER&#91;'ORIG_SCRIPT_FILENAME'&#93;&#58;$_SERVER&#91;'SCRIPT_FILENAME'&#93;&#41;&#41;&#41;&#41;;

define&#40;'PATH_site', dirname&#40;PATH_thisScript&#41;.'/'&#41;;

if &#40;@is_dir&#40;PATH_site.'typo3/sysext/cms/tslib/'&#41;&#41; &#123;
	define&#40;'PATH_tslib', PATH_site.'typo3/sysext/cms/tslib/'&#41;;
&#125; elseif &#40;@is_dir&#40;PATH_site.'tslib/'&#41;&#41; &#123;
	define&#40;'PATH_tslib', PATH_site.'tslib/'&#41;;
&#125; else &#123;

	// define path to tslib/ here&#58;
	$configured_tslib_path = 'htdocs/woy.ch/typo3/sysext/cms/tslib/';

	// example&#58;
	// $configured_tslib_path = '/var/www/mysite/typo3/sysext/cms/tslib/';

	define&#40;'PATH_tslib', $configured_tslib_path&#41;;
&#125;

if &#40;PATH_tslib==''&#41; &#123;
	die&#40;'Cannot find tslib/. Please set path by defining $configured_tslib_path in '.basename&#40;PATH_thisScript&#41;.'.'&#41;;
&#125;

// ******************
// include TSFE
// ******************

require &#40;PATH_tslib.'index_ts.php'&#41;;

?>

Die Header Infos sind folgende:

https://woy.ch/

GET / HTTP/1.1
Host: woy.ch
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.8,de-de;q=0.7,de;q=0.5,en-us;q=0.3,en;q=0.2
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Cookie: Sprache=http%3A%2F%2Fen.woy.ch; fe_typo_user=bf44a06a78fccb1bc7783ef1ad280809; be_typo_user=d88c8fdbe2ae3481223a2e568958b4ed; PHPSESSID=61faf9a88ad7c4826ecd472c4a21793b

HTTP/1.1 301 Moved Permanently
Date: Fri, 21 May 2010 10:18:11 GMT
Server: Apache
X-Powered-By: PHP/5.2.12
Location: https://de.woy.ch
Content-Length: 0
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/html
----------------------------------------------------------
https://de.woy.ch/

GET / HTTP/1.1
Host: de.woy.ch
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.8,de-de;q=0.7,de;q=0.5,en-us;q=0.3,en;q=0.2
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Cookie: Sprache=http%3A%2F%2Fen.woy.ch; fe_typo_user=57120a4e9e1221a2ece43a613c423586; PHPSESSID=3dc0ed1dfce46c6de008241b7cecb143

HTTP/1.1 200 OK
Date: Fri, 21 May 2010 10:18:11 GMT
Server: Apache
X-Powered-By: PHP/5.2.12
Set-Cookie: fe_typo_user=f6f68abc8f5e97ebe95c413ee0534e98; path=/
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=iso-8859-1

Verfasst:
von

Verfasst: 21.05.2010, 12:56
von Azubi
so habe es gelößt vielleicht braucht das mal jemand.

Code: Alles auswählen

<?php

$SiteNameURL = $_SERVER&#91;'HTTP_HOST'&#93;;


switch &#40;strtolower&#40;$SiteNameURL&#41;&#41; &#123;

case "http&#58;//www.woy.ch"&#58; //MUST BE LOWER CASE
		
		header &#40;'Location&#58;http&#58;//de.woy.ch'&#41;;die&#40;&#41;;

            break;
case "www.woy.ch"&#58; //MUST BE LOWER CASE
		  header &#40;'Location&#58;http&#58;//de.woy.ch'&#41;;die&#40;&#41;;

          break;
case "woy.ch"&#58; //MUST BE LOWER CASE
			header &#40;'Location&#58;http&#58;//de.woy.ch'&#41;;die&#40;&#41;;
            break;                        
            
&#125;



if&#40;!isset&#40;$_COOKIE&#91;'Sprache'&#93;&#41;&#41;
&#123;
$sprache = $_SERVER&#91;"HTTP_ACCEPT_LANGUAGE"&#93;;
$sprache = explode &#40;',',$sprache&#41;;

switch&#40;$sprache&#91;0&#93;&#41; &#123;

case 'de-DE'&#58; 

if &#40;stristr&#40;$sprache&#91;0&#93;,'US'&#41;&#41;&#123;
	setcookie&#40;"Sprache", $weiterleitung&#41;;
    header &#40;'Location&#58;http&#58;//en.woy.ch'&#41;;break;
&#125;

if &#40;stristr&#40;$sprache&#91;0&#93;,'ES'&#41;&#41;&#123;
	setcookie&#40;"Sprache", $weiterleitung&#41;;
    header &#40;'Location&#58;http&#58;//es.woy.ch'&#41;;break;
&#125;
setcookie&#40;"Sprache", $weiterleitung&#41;;
header &#40;'Location&#58;http&#58;//de.woy.ch'&#41;;die&#40;&#41;;


case 'en-US'&#58; 

if &#40;stristr&#40;$sprache&#91;0&#93;,'DE'&#41;&#41;&#123;
	setcookie&#40;"Sprache", $weiterleitung&#41;;
 	header &#40;'Location&#58;http&#58;//de.woy.ch'&#41;;die&#40;&#41;;break;
&#125;

if &#40;stristr&#40;$sprache&#91;0&#93;,'ES'&#41;&#41;&#123;
	setcookie&#40;"Sprache", $weiterleitung&#41;;
    header &#40;'Location&#58;http&#58;//es.woy.ch'&#41;;break;
&#125;
	setcookie&#40;"Sprache", $weiterleitung&#41;;
    header &#40;'Location&#58;http&#58;//en.woy.ch'&#41;;break;

case 'es-ES'&#58; 

if &#40;stristr&#40;$sprache&#91;0&#93;,'DE'&#41;&#41;&#123;
   setcookie&#40;"Sprache", $weiterleitung&#41;;
   header &#40;'Location&#58;http&#58;//de.woy.ch'&#41;;die&#40;&#41;;
&#125;

if &#40;stristr&#40;$sprache&#91;0&#93;,'EN'&#41;&#41;&#123;
	setcookie&#40;"Sprache", $weiterleitung&#41;;
    header &#40;'Location&#58;http&#58;//en.woy.ch'&#41;;break;
&#125;
	setcookie&#40;"Sprache", $weiterleitung&#41;;
    header &#40;'Location&#58;http&#58;//es.woy.ch'&#41;;break;
&#125;

&#125;


if &#40;defined&#40;'E_DEPRECATED'&#41;&#41; &#123;
	error_reporting&#40;E_ALL ^ E_NOTICE ^ E_DEPRECATED&#41;;
&#125; else &#123;
	error_reporting&#40;E_ALL ^ E_NOTICE&#41;;
&#125;


// ******************
// Constants defined
// ******************

define&#40;'PATH_thisScript',str_replace&#40;'//','/', str_replace&#40;'\\','/', &#40;PHP_SAPI=='cgi'||PHP_SAPI=='isapi' ||PHP_SAPI=='cgi-fcgi'&#41;&&&#40;$_SERVER&#91;'ORIG_PATH_TRANSLATED'&#93;?$_SERVER&#91;'ORIG_PATH_TRANSLATED'&#93;&#58;$_SERVER&#91;'PATH_TRANSLATED'&#93;&#41;? &#40;$_SERVER&#91;'ORIG_PATH_TRANSLATED'&#93;?$_SERVER&#91;'ORIG_PATH_TRANSLATED'&#93;&#58;$_SERVER&#91;'PATH_TRANSLATED'&#93;&#41;&#58;&#40;$_SERVER&#91;'ORIG_SCRIPT_FILENAME'&#93;?$_SERVER&#91;'ORIG_SCRIPT_FILENAME'&#93;&#58;$_SERVER&#91;'SCRIPT_FILENAME'&#93;&#41;&#41;&#41;&#41;;

define&#40;'PATH_site', dirname&#40;PATH_thisScript&#41;.'/'&#41;;

if &#40;@is_dir&#40;PATH_site.'typo3/sysext/cms/tslib/'&#41;&#41; &#123;
	define&#40;'PATH_tslib', PATH_site.'typo3/sysext/cms/tslib/'&#41;;
&#125; elseif &#40;@is_dir&#40;PATH_site.'tslib/'&#41;&#41; &#123;
	define&#40;'PATH_tslib', PATH_site.'tslib/'&#41;;
&#125; else &#123;

	// define path to tslib/ here&#58;
	$configured_tslib_path = 'htdocs/woy.ch/typo3/sysext/cms/tslib/';

	// example&#58;
	// $configured_tslib_path = '/var/www/mysite/typo3/sysext/cms/tslib/';

	define&#40;'PATH_tslib', $configured_tslib_path&#41;;
&#125;

if &#40;PATH_tslib==''&#41; &#123;
	die&#40;'Cannot find tslib/. Please set path by defining $configured_tslib_path in '.basename&#40;PATH_thisScript&#41;.'.'&#41;;
&#125;

// ******************
// include TSFE
// ******************

require &#40;PATH_tslib.'index_ts.php'&#41;;

?>

Verfasst: 21.05.2010, 13:14
von SloMo
Woran lag es denn?

Verfasst:
von

Verfasst: 21.05.2010, 13:38
von Azubi
>> so gehts nicht

Code: Alles auswählen

header &#40;'location&#58;'.$weiterleitung&#41;;die&#40;&#41;;

>> so gehts

Code: Alles auswählen

header &#40;'location&#58;http&#58;//de.woy.ch'&#41;;die&#40;&#41;
hat der IE nicht geschluckt, habe die Url nun direkt geschrieben

Verfasst: 22.05.2010, 06:38
von 800XE
Azubi hat geschrieben:>> so gehts nicht

Code: Alles auswählen

header &#40;'location&#58;'.$weiterleitung&#41;;die&#40;&#41;;

>> so gehts

Code: Alles auswählen

header &#40;'location&#58;http&#58;//de.woy.ch'&#41;;die&#40;&#41;
hat der IE nicht geschluckt, habe die Url nun direkt geschrieben
1. geht --- );die() ---- nicht, weil hinten das ; fehlt

2. natürlich geht ----- header ('location:'.$weiterleitung);

Code: Alles auswählen

echo &#40; $weiterleitung &#41;;
header &#40;'location&#58;'.$weiterleitung&#41;;
die&#40;&#41;;

zeigt dir was du ändern mußt damit es geht

Verfasst: 22.05.2010, 08:06
von SloMo
Abgesehe vom Wurstcode wundert mich die Browserabhängigkeit. Kann eigentlich bei einer serverseitigen Weiterleitung gar nicht sein.

Wurstcode, weil:

Code: Alles auswählen

switch&#40;$sprache&#91;0&#93;&#41; &#123; 
case 'de-DE'&#58; 
   if &#40;stristr&#40;$sprache&#91;0&#93;,'US'&#41;&#41;&#123;
   ...