与PHP中的ASP.NET HttpModules等效 [英] Equivalent of ASP.NET HttpModules in PHP

查看:31
本文介绍了与PHP中的ASP.NET HttpModules等效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么等效于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:

http://roshanbh.com.np/2008/02/hide-php-url-rewriting-htaccess.html

正式的Apache文档: http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html

Official Apache Docs: http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html

这篇关于与PHP中的ASP.NET HttpModules等效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆