问题描述
我正在做一个项目,在浏览一些代码时偶然发现了这个问题.我曾尝试用Google搜索,但找不到正确的关键字来搜索有关此问题的内容.
I am doing on a project and i stumble upon on this while going through some code. I had tried to google but could not find a correct keyword to search regarding this question.
http://www.fruit.com/example.php/red
我对此感到困惑,并且在.php
的末尾仍然有一个字符/red
.这样做的目的是什么?它与POST
方法有关吗?
I am confuse with this and the end of a .php
it still have a character /red
for example.What is the purpose of this? Does it have something to do with POST
method?
推荐答案
一个可能的解释是,开发人员正在使用.htaccess
重写规则.很有可能是与页面有关的额外数据(例如您提到的POST和GET),并且只有通过这种方式才能使URL看起来更漂亮或简化URL.
A possible explanation is that the developer is using .htaccess
rewrite rules. It is most likely extra data that has to do with the page (such as you mentioned, POST and GET) and it's only done this way to make the URL look prettier or to simplify the URL.
有时也可以通过这种方式来简化链接回该页面的操作,尤其是在基于数据生成页面的情况下.
It is also sometimes done this way to make it easier to linkback to this page, especially if the page is being generated based on the data.
最流行的地方是博客.您经常看到博客将链接显示为:
A popular place to do this would be blogs. You often see blogs display links as:
http://blog.com/blog/2001/02/23/how-pretty-is-this
实际上,对服务器的请求类似于:
when in reality, the request to the server is something like:
/blog.php?year=2001&month=02&day=23&title=how-pretty-is-this
这不是那么漂亮,并且链接回该特定页面也不那么容易.
which isn't that pretty and not as easy to link-back to this particular page.
这篇关于需要一些关于example.php/example的答案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!