-2

我需要重写网址

我的实际网址

http://www.domain.com/page.php?catName/ArticleName....?/&ca=7&prod=44&artId=446

我需要像这样重写

http://www.domain.com/catID-catName/proID-prodName/artID-ArticleName....?/page.html

4

1 回答 1

3

对的,这是可能的。顺便说一句,您修改后的 URL 只有一个“?”。在 [RFC][1] 中指定了 URI 和 URL 的语法,它query是 URL 中跟在http://www.example.com/pathor http://www.example.com(路径是可选的)组件之后的部分。注意“?” 字符必须是 URL 查询部分的第一个字符。

RFC 3.4 节中的关键句是

字符斜线(“/”)和问号(“?”)可以表示查询组件内的数据。

这是管理 URI 语法的 RFC 的相关部分。

3.4 Query

The query component contains non-hierarchical data that, along with
   data in the path component (Section 3.3), serves to identify a
   resource within the scope of the URI's scheme and naming authority
   (if any).  The query component is indicated by the first question
   mark ("?") character and terminated by a number sign ("#") character
   or by the end of the URI.

      query       = *( pchar / "/" / "?" )

   The characters slash ("/") and question mark ("?") may represent data
   within the query component. Beware that some older, erroneous
   implementations may not handle such data correctly when it is used as
   the base URI for relative references (Section 5.1), apparently
   because they fail to distinguish query data from path data when
   looking for hierarchical separators.  However, as query components
   are often used to carry identifying information in the form of
   "key=value" pairs and one frequently used value is a reference to
   another URI, it is sometimes better for usability to avoid percent-
   encoding those characters.


  [1]: http://tools.ietf.org/html/rfc3986#section-3
于 2013-03-23T09:09:01.910 回答