PHP中的URL映射? [英] URL mapping in PHP?

查看:36
本文介绍了PHP中的URL映射?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我来自 Java 背景并且使用任何基于 servlet 的技术,将一系列 URL(例如/reports/、/secure/.do)映射到指定的 servlet 是微不足道的.现在我对 PHP 不太熟悉,但我还没有看到任何与 PHP(或 mod_php)完全相同的东西.我完全有可能遗漏了一些简单的东西.

I come from a Java background and with any servlets-based technology, it's trivial to map a range of URLs (eg /reports/, /secure/.do) to a specified servlet. Now I'm less familiar with PHP but I haven't yet seen anything that does quite the same thing with PHP (or mod_php). It's entirely possible that I'm missing something simple.

您如何在 PHP 中执行此操作?

How do you do this in PHP?

我想要这样做的原因之一是一次性"网址.现在这可以通过 GET 参数(如 MD5 哈希令牌)完成,但我对 URL 映射感兴趣,作为许多问题的通用解决方案.

One of the reasons I want to do this is "one use" URLs. Now this can sorta be done with GET parameters (like an MD5 hash token) but I'm interested in URL mapping as a general solution to many problems.

使用此类内容的另一个重要原因是拥有 RESTful URL.

Another big reason to use something like this is to have RESTful URLs.

推荐答案

使用 Apache,您可以使用 mod_rewrite 为您的 php 页面设置 URL 重写,请查看以下资源:

With Apache, you are able to setup URL Rewriting for your php pages with mod_rewrite, check this resources:

这篇关于PHP中的URL映射?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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