gerkintrigg Posted June 18, 2012 Share Posted June 18, 2012 Hi. I have a neat little script which outputs my database as XML here: http://98.131.0.168/~truro/sitemap.php I'm trying to use Mod Re-Write to tell google and others that the PHP script is a XML page by adding this to a .htaccess file: RewriteRule (.*)\.xml(.*) $1.php$2 [nocase] It's just not working. Here's the URL: http://98.131.0.168/~truro/sitemap.xml Any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/264401-php-as-xml-using-mod-re-write/ Share on other sites More sharing options...
requinix Posted June 19, 2012 Share Posted June 19, 2012 header("Content-Type: application/xml"); Before you output anything. But are you sure you need this? It's already being sent as text/xml which is probably okay. Is there a problem you need to fix? Quote Link to comment https://forums.phpfreaks.com/topic/264401-php-as-xml-using-mod-re-write/#findComment-1355042 Share on other sites More sharing options...
gerkintrigg Posted June 19, 2012 Author Share Posted June 19, 2012 This header is already there. The PHP page is working fine, but the mod re-write will not recognise the PHP page as an XML page. I need this to work so that Google can look for sitemap.xml and find the PHP page that accesses my database. Mod rewrite's working for other pages, but seems to have a problem with the line (above) which changes an XML page into a PHP one. Neil Quote Link to comment https://forums.phpfreaks.com/topic/264401-php-as-xml-using-mod-re-write/#findComment-1355069 Share on other sites More sharing options...
requinix Posted June 19, 2012 Share Posted June 19, 2012 ...mod_rewrite has nothing to do with it. Google, and everything that downloads files, cares about what you claim the file is. And that's what the header() is for. If text/xml doesn't work well then try application/xml. Quote Link to comment https://forums.phpfreaks.com/topic/264401-php-as-xml-using-mod-re-write/#findComment-1355072 Share on other sites More sharing options...
gerkintrigg Posted June 19, 2012 Author Share Posted June 19, 2012 No I don't think you're getting what I mean.... The file works fine. Mod re-write is used to handle URL parsing. I want someone to enter "sitemap.xml" into their browser and be directed to the "sitemap.php" page that already works fine. This is a mod-rewrite issue, not a PHP/XML one. that's why this post is in this forum as opposed to anywhere else. I hope that helps. Quote Link to comment https://forums.phpfreaks.com/topic/264401-php-as-xml-using-mod-re-write/#findComment-1355077 Share on other sites More sharing options...
requinix Posted June 19, 2012 Share Posted June 19, 2012 Oh... you want the URL to look different? You know the extension means nothing technically, right? RewriteRule ^sitemap.xml$ sitemap.php [L] Quote Link to comment https://forums.phpfreaks.com/topic/264401-php-as-xml-using-mod-re-write/#findComment-1355248 Share on other sites More sharing options...
Tarential Posted July 11, 2012 Share Posted July 11, 2012 As I understand it, one defines the location of the sitemap xml file in robots.txt; it does not need to be called sitemap.xml: http://www.sitemaps.org/protocol.html#submit_robots It is also possible to submit the sitemap to Google directly. That said, it still seems like a good idea to have a forward from sitemap.xml. Quote Link to comment https://forums.phpfreaks.com/topic/264401-php-as-xml-using-mod-re-write/#findComment-1360766 Share on other sites More sharing options...
gerkintrigg Posted July 11, 2012 Author Share Posted July 11, 2012 I got it working eventually here: http://www.truro.com/sitemap.xml Quote Link to comment https://forums.phpfreaks.com/topic/264401-php-as-xml-using-mod-re-write/#findComment-1360783 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.