Rendering plain text through PHP
- by JP19
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