网址与多个斜杠,它破坏任何东西? [英] url with multiple forward slashes, does it break anything?

查看:236
本文介绍了网址与多个斜杠,它破坏任何东西?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://example.com/something/somewhere//somehow/script.js

请问双斜线打破服务器端的东西吗?我有一个网址解析的脚本,我不知道它是否会破坏任何东西(或更改路径)如果我换成多个斜线用一个斜线。特别是在服务器端,比如codeIgniter和Joomla使用一些框架分段URL方案和路由。我只是想知道,如果它打破什么。

Does the double slash break anything on the server side? I have a script that parses URLs and i was wondering if it would break anything (or change the path) if i replaced multiple slashes with a single slash. Especially on the server side, some frameworks like CodeIgniter and Joomla use segmented url schemes and routing. I would just want to know if it breaks anything.

推荐答案

2396 定义路径分隔符是的单斜线

HTTP RFC 2396 defines path separator to be single slash.

然而,除非你使用某种URL重写(在这种情况下,重写规则可以由斜杠的数量的影响),在URI映射到磁盘上的路径,但在(大多数?)现代操作系统(的Linux / Unix,Windows)中,连续多路径分隔符不具有任何特殊含义,所以/路径/到/ foo和/路径//到//// foo的最终映射到同一个文件。

However, unless you're using some kind of URL rewriting (in which case the rewriting rules may be affected by the number of slashes), the uri maps to a path on disk, but in (most?) modern operating systems (Linux/Unix, Windows), multiple path separators in a row do not have any special meaning, so /path/to/foo and /path//to////foo would eventually map to the same file.

这可能会影响到另外一个就是缓存。由于这两种浏览器和服务器缓存单独的页面(根据自己的缓存设置),通过请求相同的文件多次的的不同的URI可能会影响缓存(取决于服务器和客户端实现)。

An additional thing that might be affected is caching. Since both your browser and the server cache individual pages (according to their caching settings), requesting same file multiple times via slightly different URIs might affect the caching (depending on server and client implementation).

这篇关于网址与多个斜杠,它破坏任何东西?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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