I want to build a sitemap dynamically only when requested by GoogleBot or BingBot and then save it to sitemap.xml, and when other user request it just show then already created sitemap.xml. How to do this ?
Edit
How to serve sitemap.php as sitemap.xml ?
If you want to save your file as .xml and execute it as a PHP file, you’ll need to add something along these lines to your .htaccess file: