Jump to content

PHP as XML using Mod-Re-write


Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/264401-php-as-xml-using-mod-re-write/
Share on other sites

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

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.

  • 3 weeks later...

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.