Rendering plain text through PHP

Posted by JP19 on Stack Overflow See other posts from Stack Overflow or by JP19
Published on 2010-12-22T06:20:04Z Indexed on 2010/12/22 6:54 UTC
Read the original article Hit count: 425

Filed under:
|
|
|
|

Hi,

For some reason, I want to serve my robots.txt via a PHP script. I have setup apache so that the robots.txt file request (infact all file requests) come to a single PHP script.

The code I am using to render robots.txt is:

echo "User-agent: wget\n";
echo "Disallow: /\n";

However, it is not processing the newlines. How to server robots.txt correctly, so search engines (or any client) see it properly? Do I have to send some special headers for txt files?

EDIT:

Now I have the following code:

header("Content-Type: text/plain");
echo "User-agent: wget\n";
echo "Disallow: /\n";

which still does not display newlines (see http://sarcastic-quotes.com/robots.txt ).

EDIT 2:

Some people mentioned its just fine and not displayed in browser. Was just curious how does this one display correctly: http://en.wikipedia.org/robots.txt

thanks

JP

© Stack Overflow or respective owner

Related posts about php

Related posts about text