开发者

Making a content generator Apache module that only works for text/html requests

The title of this question may be a bit misleading. I couldn't quite think of anything better.

Here is my problem. I am de开发者_如何学编程veloping an Apache module that needs to manipulate a bit of content in the requested HTML document (this document can be a file on the disk or may be dynamically generated by CGI or PHP) and so I am using libxml2 with it.

I developed something working, but the problem is that when the browser requests for a page, let's say

http://localhost/a.html

the module does it's job. But if that page has references to a javascript file, a.js, or a stylesheet file, a.css, they are not getting served.

The reason as I perceived by examining the logs is that, as the browser sends requests for a javascript file let's say

[http://localhost/a.js] //putting [] because of limit of 1 url per post.

Apache again runs my module, the module uses a HTML parser, so when the content is not HTML, it gives error and exits, the request is abandoned.

How can I make my module to work only for text/html requests ?


I don't know how to make your module to decline the request. But if you don't figure how to do it you can just configure it in httpd.conf

AddHandler my-handler .html
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜