0

I've got a PHP file containing only this :

<?php header( 'Location: http://www.yahoo.com'); ?>

Redirection works locally but not on my Blue Host server. Support department says I must change my PHP file's character encoding from UTF8 to ASCII and it will work. However I have no idea how to do that. Is there a free software that does it easily, or any other way ?

3
  • 1
    get a new host with better control over your server. Commented Feb 5, 2013 at 12:48
  • Changing character encoding depends on the editor you are using for coding. Which editor are you using? Commented Feb 5, 2013 at 12:50
  • @Hiroto PHP requires ASCII compatible encoding no matter what the server. UTF-8 is ASCII compatible as long as you don't use the BOM. Normal notepad will insert BOM when saving as UTF-8, with Notepad++ one can choose UTF-8 Without BOM-encoding. Commented Feb 5, 2013 at 14:31

2 Answers 2

4

That's why you should never ask programming questions to the HSP support guys. It's out of their scope and in the best case they'll provide some bogus advice like this.

Whatever, it's possible that there's some truth in the reference to UTF-8. Check your editor settings and make sure your UTF-8 files do not contain BOM (Unicode Byte Order Marker). It isn't mandatory and most applications get confused with it, esp. PHP itself.

Sign up to request clarification or add additional context in comments.

1 Comment

+1: An excellent analysis of the question. If the file is saved as UTF-8 + BOM, PHP sees the BOM as a printable character outside of the <?php tags, and thus it can't do a redirect because it's already sent output, that output being the BOM character. Just change the encoding to UTF-8 without the BOM and you'll be fine.
1

In newer versions of notepad (windows) you can select the encoding when you 'Save as'.

Otherwise use notepad++ which has an encoding menu.

4 Comments

...or even use a proper IDE like eclipse or netbeans.
I used Notepad++ and was able to change the file format from UTF8 to ANSI (there's no ASCII anywhere). However redirection still doesn't work. Any suggestion guys?
ANSI is extended ASCII Your code looks fine maybe your hosting has restrictions on some PHP-functions?
Sorry I'm mistaken. Changing charset from UTF-8 to ANSI fixed the problem. Thanks all for the help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.