Sami El Hilali
Sami El Hilali

Reputation: 1031

Header does not work on my server

Please I have a small problem on my server :

When I use the php "header" function, it doesn't work :

header('location: /index.html');

I tried this line on another server with the same php version and it works finely !

PHP version : 5.1.65

Please any advice ?

Upvotes: 0

Views: 411

Answers (3)

Alpha
Alpha

Reputation: 453

As Dylan Cross mentioned you mustn't have HTML output before the header.

If you have required a library before calling "header", it might contain the html -without paying attention- in the fallowing way :

<?php 

   // Code here

?>{If there is a space after this close tag, it's considered as an HTML output}

In this case you need to check all your libraries...

Upvotes: 1

Adam
Adam

Reputation: 1264

Try this you missed out the colon(:):

header('location: /index.html');

Upvotes: 0

Marc B
Marc B

Reputation: 360562

header('Location: /index.html');
                ^---missing colon

Upvotes: 2

Related Questions