我需要重写网址
我的实际网址
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
答案 0 :(得分:3)
是的,这是可能的。顺便说一下,您修改过的网址只有一个'?'。
从[RFC] [1]指定URI和URL的语法,query
是跟随http://www.example.com/path
或http://www.example.com
(路径是可选的)组件的URL的一部分。注意“?” character必须是URL查询部分的第一个字符。
RFC第3.4节中的关键句是
字符斜杠(“/”)和问号(“?”)可能代表查询组件中的数据。
以下是RFC管理URI语法的相关部分。
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