Forum Moderators: phranque

Message Too Old, No Replies

Creating a custom handler

I need a php handler...

         

Blue_Jeans

4:03 am on May 15, 2008 (gmt 0)

10+ Year Member



I'm sick of making two files for my xml files. One for xml, and one to convert. So I thought I'd just make a custom php handler.
.htaccess:

AddHandler myXML .xml
Action myXML xmlParser.php

xmlParser.php

<?php
$id = getenv("REQUEST_URI");
$parser = xslt_create();
$html = xslt_process($parser, $id,
"template.xsl");
xslt_free($parser);

echo $html;
?>

Except, it doesn't work. I've never tried anything like this before. I get a "400 Bad Request: Your browser sent a request that this server could not understand."

I thought it might be simple, but it looks like it might not be. Could someone do one of the following:
A) Show me my mistake
B) Do it for me
C) Point me to some good tutorials on how to do what I want to do.
?

jdMorgan

9:08 pm on May 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> One for xml, and one to convert

Sorry, but one to convert to what?

I believe this is essentially a PHP question, and might do better in our PHP forum.

Jim

Blue_Jeans

10:27 pm on May 15, 2008 (gmt 0)

10+ Year Member



Oops, I forgot to append "on the server" after "one to convert"...

The problem I am having is NOT the php file. My trouble is
A) Associating it with every XML file
B) Not sure, but I think the php script should technically be classified as cgi-script?

The ideas is that every XML file gets converted on the server, and I cannot install things such as mod-xslt(2) because pcre-config isn't installed on my server, and after two hours of tech support with my hosting provider taught me that after two hours the answer is always, "No, we can't add that functionality at this time on shared hosting packages." What a bummer.

It seemed like to me this approach should work... I just don't know HOW to make it work with apache.

[edited by: Blue_Jeans at 10:29 pm (utc) on May 15, 2008]