什么等效于PHP中的ASP.NET HttpModules?
what is the equivalent of ASP.NET HttpModules in PHP?
如果有什么可以针对特定应用程序(不是全局)包含它们的,换句话说,相当于web.config
If there are any how can I include them for that specific application (not globally) in other words what is the equivalent of web.config
示例:如果服务器返回HTTP 500错误(无论运行的代码如何),我都需要记录请求和标头.
Example : I need to log the request and the headers, if the server is returning a HTTP 500 error irrespective of the code which is run.
在ASP.NET中,我将拥有一个HTTP模块,在发送给客户端之前,我可以在其中获取响应代码和其他详细信息.我也可以处理Begin Request.
In ASP.NET, I would have a HTTP Module in which I can grab the response code and other details, before sending to the client. I can also handle Begin Request.
我需要在PHP中使用类似的东西
I need something similar in PHP
推荐答案不幸的是,PHP更像ASP,因为应用程序"是一个松散的概念,文件之间没有紧密的联系,因此您所做的任何事情都可能具有处于网络服务器级别
Unfortunately PHP is more like ASP in the sense that the "application" is a loose concept, the files are not tightly related, so anything you do would likely have to be at the web server level
假设您在linux/apache服务器上.一种方法是使用.htaccess,可以在目录(即应用程序级别)上修改这些文件并具有强大的功能.
Assuming you are on a linux/apache server. One approach would be to use .htaccess, these can be modified at the directory (ie application level) and have sever powerful features.
其中一个网址重写示例:
One example is for url re-writing:
roshanbh.np/2008/02/hide-php-url-rewriting-htaccess.html
正式的Apache文档: httpd.apache/docs/1.3/mod/mod_rewrite.html
Official Apache Docs: httpd.apache/docs/1.3/mod/mod_rewrite.html
更多推荐
与PHP中的ASP.NET HttpModules等效
发布评论