与PHP中的ASP.NET HttpModules等效

编程入门 行业动态 更新时间:2024-10-24 18:25:22
本文介绍了与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:

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等效

本文发布于:2023-11-16 18:39:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1606816.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:ASP   PHP   HttpModules   NET

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!