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

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

问题描述

我来自一个Java的背景,并与任何基于servlet的技术,是微不足道的一个范围内的URL(例如/报告/ ,/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?

一个我想要做的,这是一用的URL的原因。现在,这可以用八九不离十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.

另一大理由使用这样的事情是有REST风格的URL。

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

推荐答案

使用了Apache,你可以设置URL重写PHP页面与mod_rewrite的,看看这个资源:

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

  • mod_rewrite: A Beginner's Guide to URL Rewriting
  • Module mod_rewrite
  • URL Rewriting Guide

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

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