Yes, using PHP's header function to redirect visitors (German / Deutsch)

by Matthew Kastor, Saturday, March 05, 2011, 17:53 (4804 days ago) @ apfelsino
edited by Matthew Kastor, Saturday, March 05, 2011, 18:02

Gibt es eine Möglichkeit das Forum per include in die Homepage einzubauen?
Ich habe das Forum im Ordnuner /forum/ liegen und rufe die Seiten per "index.php?seite=forum" auf.

Wenn ich jetzt die index.php include, erhalte ich folgende Error-Meldungen:

"Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at index.php:9) in /forum/index.php on line 29

Warning: Smarty error: unable to read resource: "german.lang" in /forum/modules/smarty/Smarty.class.php on line 1093

Warning: Cannot modify header information - headers already sent by (output started at /index.php:9) in /forum/index.php on line 205

Warning: Cannot modify header information - headers already sent by (output started at /index.php:9) in /forum/index.php on line 207

Warning: Smarty error: unable to read resource: "default/main.tpl" in /forum/modules/smarty/Smarty.class.php on line 1093"

Gibt es da überhaupt eine Möglichkeit mit einem include? Oder könnte ich das Forum z.B. nur als iframe direkt in die Seite einbauen?

via Google Translate:

Is there a way to install the forum in your script in the home?
I Ordnuner in the forum / forum have /, and call the pages by "index.php? Page = forum" on.

If I include the index.php, I get the following error messages:

Warning: session_start () [function.session-start]: Can not send session cache limiter - headers already sent by (output started at index.php: 9) in / forum / index.php on line 29

Warning: Smarty error: unable to read resource: "german.lang" in / forum / modules / smarty / Smarty.class.php on line 1093

Warning: Can not modify header information - headers already sent (output started at / index.php: 9) in / forum / index.php on line 205

Warning: Can not modify header information - headers already sent (output started at / index.php: 9) in / forum / index.php on line 207

Warning: Smarty error: unable to read resource: "default / main.tpl" in / forum / modules / smarty / Smarty.class.php on line 1093 "

Is there any possibility to include one? Or I could be the forum for example only as iframe directly built into the side?


Including index.php will give you the error:

Warning: session_start () [function.session-start]: Can not send session cache limiter - headers already sent by (output started at index.php: 9) in / forum / index.php on line 29

because the file you are including it in has already sent headers. Your server has to send the headers before anything else. http://php.net/manual/en/function.header.php

The other header errors are also caused by this.

The smarty errors are caused by including the file located in http://yoursite.com/forum because they don't know you are running them from a different location. They are looking for "german.lang" and "default / main.tpl" relative to the location they expect to be in.

I left a message a few minutes ago that you could use an .htaccess file with rewrite rules in it if you are using an Apache server. This will work perfectly. I have another solution for you. If you are not using Apache, then you can send visitors to your forum automatically when they arrive at your website with one line of PHP code. This will work from anywhere in your site, place the file in the folder accessed when visitors first arrive.

name it index.php


<?php
header("Location: http://yoursite.com/forum/");
?>

The second special case is the "Location:" header. Not only does it send this header back to the browser, but it also returns a REDIRECT (302) status code to the browser unless the 201 or a 3xx status code has already been set. -- PHP.net Manual


Do you know if there is a good add-on for Thunderbird to translate my email? That would be very good. :-D


Complete thread:

 RSS Feed of thread