我正在托pipe一个图片服务器,在那里我的客户上传他们的照片供以后的客户查看。 我们已经将我们的网站从Windows服务器迁移到Linux。 我们的一些客户习惯于能够在文件名中使用括号。 这个过去在我们的Windows环境下工作,而不是在我们移动到的Apache / Linux环境中,我们得到了404。当我们修改文件,删除括号,我们能够为它服务。 有没有一种方法,我们可以允许Apache的文件名中括号括起来?
这是因为括号是RFC 3986保留的,不允许的。 如果您希望在URL中使用这些字符,则需要对这些字符进行百分比编码。
URIs include components and subcomponents that are delimited by characters in the "reserved" set. These characters are called "reserved" because they may (or may not) be defined as delimiters by the generic syntax, by each scheme-specific syntax, or by the implementation-specific syntax of a URI's dereferencing algorithm. If data for a URI component would conflict with a reserved character's purpose as a delimiter, then the conflicting data must be percent-encoded before the URI is formed. reserved = gen-delims / sub-delims gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@" sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
如果你得到一个404,因为它没有编码,实际上并没有看正确的文件,因为parens被解释为分隔符。 你想要做的是,假设你有一个文件some_image_(huzzah) ,你需要在URI中表示为some_image_%28huzzah%29 。