Jump to content

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

...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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.