Forum Moderators: phranque

Message Too Old, No Replies

used php in xml pages. now pure xml pages dont work

         

achshar

11:05 am on Aug 30, 2010 (gmt 0)

10+ Year Member



AddType application/x-httpd-php .xml 


i used this in my htaccess file to make php work in xml pages.. now if a xml page conatins only xml then a php error comes up

Parse error: syntax error, unexpected T_STRING in foo/BingSiteAuth.xml on line 1

this is the new bing webmaster site auth file..

the old one somehow worked..
BTW i guess it is <?xml which causes the error..

how can i get over this?

i have a workaround.. one can echo the content but it would be a pain to echo some huge content.. i would rather prefer a more stable solution to this.. :)
thanks..

jdMorgan

12:57 pm on Aug 30, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Other than echoing, the options in .htaccess might include surrounding your "AddType" directive with <Files>, <FilesMatch>, and/or <Limit> containers to limit the scope of that directive. If you have server config file access, then you have the added ability to use <Directory> or <Location> containers.

Do note that <Files> and <FilesMatch> directive consider filenames only. No directory-path information is considered, and a filepath is not a URL...

See "Apache core" documentation for details on these containers.

Jim

achshar

1:23 pm on Aug 30, 2010 (gmt 0)

10+ Year Member



my site's structure has a number of pages that have php in xml in random depth at almost all of the major directories.. i dont really think the directory or location directives could be used..

and as for the files filesmatch and limit containers what i have been able to understand from the docs (plz pardon if i got it wrong) is that they limit the addtype's action to listed file types but for me the file type is xml same all over the site..

i would be greatly helpful if you could illuminate me on the use of file, filematch and limit containers..

i needed php for sitemaps and feeds.. i certainly cannot manually add the urls in files..

jdMorgan

2:21 pm on Aug 30, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I did not say this would be easy. You need to look at the tools available (such as <FilesMatch> and mod_rewrite) and then re-arrange things (change your filenames, for example) to make it possible to use those tools to solve your problem.

If that means renaming your xml-within-php files from ".xml" to ".pxm" and using mod_rewrite to map their ".xml" URLs to ".pxm" filepaths so that <FilesMatch> can detect them (and the URLs won't have to change), so be it.

Or look into mod_rewrite RewriteRule's [T=] flag, which can be used to do an "AddType" as well.

Take your time developing the conventions that you will use to solve this problem. Think it through and make your solution future-proof so that you won't have to go through this exercise again. Pick a solution that you can live with for 25 years, not just 18 months.

I have not faced this problem myself. All of the above are simply suggestions about tools and methods for you to think about, research, and test.

[added] <Files> matches entire filenames. It also has support for limited use of regular expressions pattern-matching of filenames, filetypes, or parts of filenames and filetypes. <FilesMatch> offers full regular-expressions pattern matching, again for matching filenames, filetypes, or parts of filenames and filetypes.

<DirectoryMatch> and <LocationMatch> offer the same kind of regex support. [/added]

Jim