Jump to content

Php - Redirect


Recommended Posts

Hi

I'm new to html and PHP and ended up coming to a point where I have no more knowledge and the Internet solutions don't work...

 

So I’m trying to do a simple PHP-redirect after a mobile detection:

 

<?php
// Include the mobile device detect class
require_once 'Mobile_Detect.php';
// Init the class
$detect = new Mobile_Detect;
// checking if the user comes with a mobile device
if ($detect->isMobile()) {
   // Detects any mobile device.
   // Redirecting
   header("Location: http://www.ahornung.heliohost.org/mob");}
   else 
   {header("Location: http://www.ahornung.heliohost.org/pc");}
?>   


Well on my PC, it’s a XAMPP-Server, I get my redirect but on the online-Server (Helios) I get this back:

Warning: Cannot modify header information - headers already sent by

 

So I hope someone could help me.

Thanks for your help

 

adho12

 

p.s. Sorry for my English

  • Like 1
Link to comment
Share on other sites

<html>
<head>
</head>
<body>
<?php
// Include the mobile device detect class
require_once 'Mobile_Detect.php';
// Init the class
$detect = new Mobile_Detect;
// And here is the magic - checking if the user comes with a mobile device
if ($detect->isMobile()) {
   // Detects any mobile device.
   // Redirecting
   header("Location: http://www.ahornung.heliohost.org/mob");}
   else
   {header("Location: http://www.ahornung.heliohost.org/pc");}
?>  
WEITERLEITUNG FOLGT!
</body>
</html>

 

This is the rest of the Code, so No html...

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...