简体   繁体   English

URL中文件名后的目录?

[英]Directories after the filename in a URL?

I am updating a PHP-based site and the URL looks like this: 我正在更新一个基于PHP的站点,URL如下所示:

http://www.thesite.com/index.php/what/are/these

Can somebody give me an idea as to what is going on after the index.php ? 有人可以给我一个关于index.php之后发生什么的想法吗? It looks like directories to me, but there are none that I can see with the same names. 对我来说,它看起来像是目录,但看不到具有相同名称的目录。 Is this some sort of URL rewriting? 这是某种URL重写吗?

PS the CMS is Jetbox v2.1 PS CMS是Jetbox v2.1

Someone, somewhere, is using $_SERVER['PATH_INFO'] . 某处某人正在使用$_SERVER['PATH_INFO'] It is a server variable set by eg Apache 2 and gives the remainder of the URL after the object (document/script/w/ever) found in URL being served. 它是服务器变量,例如由Apache 2设置,并在提供URL中找到的对象(文档/脚本/以前)之后给出URL的其余部分。

Yes, that looks like URL rewriting to me. 是的,这似乎是URL重写给我的。 Without more info I can't be more specific. 没有更多信息,我无法更具体。

You're usually going to see URLs like these when the host in which the server is running does not support .htaccess but the programmer still wanted to have "pretty urls" - I know for a fact that CakePHP has their URLs look this way in this situation, as does CodeIgniter . 当运行服务器的主机不支持.htaccess时,您通常会看到这样的URL,但是程序员仍然希望拥有“漂亮的url”-我知道CakePHP的URL在这种情况下看起来像这样这种情况与CodeIgniter一样 It could also simply be manually done, but I'd bet on the author using a framework of some sort. 也可以简单地手动完成,但是我敢打赌作者使用某种框架。

Probably. 大概。 You'll want to do the following: 您需要执行以下操作:

  • Look at the .htaccess file for any RewriteRule directives 在.htaccess文件中查看任何RewriteRule指令
  • Look in index.php to see if it's using any $_SERVER variables (like $_SERVER['QUERY_STRING']) 查看index.php以查看是否正在使用任何$ _SERVER变量(例如$ _SERVER ['QUERY_STRING'])
  • Look at the logs to see what files are actually being sent to the client 查看日志以查看实际上正在向客户端发送什么文件

This extra information is passed to the script to do with as it pleases. 这些额外的信息将根据需要传递给脚本。

In PHP, you can find its value in $_SERVER['PATH_INFO'] 在PHP中,您可以在$_SERVER['PATH_INFO']找到其值

MVC routes? MVC路线? It's just a guess, I'm not familiar with any MVC implementation in PHP (haven't used PHP since 4.0). 只是一个猜测,我对PHP中的任何MVC实现都不熟悉(自4.0以来从未使用过PHP)。

是的,这是由于使用了MVC框架,例如CodeIgniter

Those are generally used a like GET variables, it's just a way of passing information along with your request. 这些通常像GET变量那样使用,这只是一种将信息与您的请求一起传递的方式。 There are a few different ways to implement this but the aim is usually to have cleaner looking urls. 有几种不同的方法可以实现此目的,但通常目的是使URL看起来更整洁。 I'm confused why they left the index.php in there - it could be a poorly done homebrew attempt. 我很困惑他们为什么将index.php留在其中-可能是自制尝试不佳。 (Not that I have anything against homebrew solutions for common problems - best way to learn IMO) (并不是说我有反对自制软件解决常见问题的任何方法-学习IMO的最佳方法)

If you want to figure out more, look for instances in the code where information is needed about which article to pull, etc... See where that information is coming from and work backwards. 如果您想了解更多信息,请在代码中查找实例,这些实例需要有关要拉的文章的信息,等等。...查看该信息来自何处并向后工作。 If you can't figure out how it works from the code then go through .htaccess and look for url rewriting logic. 如果您无法从代码中弄清楚它是如何工作的,请遍历.htaccess并查找url重写逻辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM