In this in post we learn how to generate compressed XML sitemap with php. If some reason Apache does not support gzipping - old version, modules not enabled etc, you can use PHP to generate the compressed XML sitemap. PHP comes with a module of its own to generate gzipped content. Execute phpinfo() and look for the strings "deflate" and "gzip", if you found them, you are ready to start outputting compressed content right away, all you have to do is send the header header('content-type: application/x-gzip') to send the content as a gzipped file.
Following example show you how you can do that:
Following example show you how you can do that:
<?php /* Online PHP Examples with Source Code website: http://4evertutorials.blogspot.com/ */ $file_name = 'sitemap.xml'; header('content-type: application/x-gzip'); header('Content-Disposition: attachment; filename="'.$file_name.'.gz"'); $data = "dynamic XML sitemap string goes here"; $gzdata = gzencode($data, 9); echo $gzdata; ?>
0 comments:
Post a Comment