动态 URL 与 tuckey urlrewritefilter
Dynamic URL with tuckey urlrewritefilter
我有多个 link 喜欢
- http://example.com/link1/title-with-detail
- http://example.com/link2/title-with-detail
- http://example.com/link3/title-with-detail
等等...
我有一个 tuckey 规则,它工作得很好:
<rule>
<from>^/([^/]+)/([^/]+)/type/([a-z]+)$</from>
<to>/page?slug=&type=</to>
</rule>
对于link喜欢
- http://example.com/link1/title-with-detail/type/text
但是当我使用这个规则时,即
<rule>
<from>^/([^/]+)/([^/]+)$</from>
<to>/page?slug=</to>
</rule>
我的分页符,因为在 slug 中正在获取 styles.css、functions.js 等参数。为此,我尝试使用 tuckey 的条件来排除等于前面提到的文本,即 js
、css
、png
等。但我不知道要形成什么确切条件,因为我是正则表达式的新手。请指导。
你可以这样设置条件:
<condition type="request-uri">^(?!.*\.(?:jpg|png|css|js)$).*$</condition>
根据specifiactions,你可以检查条件中的request-uri
类型,从而检查它以什么结尾:
request-uri
- Returns the part of this request's URL from the protocol name up to
the query string in the first line of the HTTP request
否定先行 (?!.*\.(?:jpg|png|css|js)$)
实际上会检查 URI 是否未以非捕获组中列出的任何扩展名结尾。您可以在 |
符号后添加更多要排除的扩展名。
我有多个 link 喜欢
- http://example.com/link1/title-with-detail
- http://example.com/link2/title-with-detail
- http://example.com/link3/title-with-detail
等等...
我有一个 tuckey 规则,它工作得很好:
<rule>
<from>^/([^/]+)/([^/]+)/type/([a-z]+)$</from>
<to>/page?slug=&type=</to>
</rule>
对于link喜欢 - http://example.com/link1/title-with-detail/type/text
但是当我使用这个规则时,即
<rule>
<from>^/([^/]+)/([^/]+)$</from>
<to>/page?slug=</to>
</rule>
我的分页符,因为在 slug 中正在获取 styles.css、functions.js 等参数。为此,我尝试使用 tuckey 的条件来排除等于前面提到的文本,即 js
、css
、png
等。但我不知道要形成什么确切条件,因为我是正则表达式的新手。请指导。
你可以这样设置条件:
<condition type="request-uri">^(?!.*\.(?:jpg|png|css|js)$).*$</condition>
根据specifiactions,你可以检查条件中的request-uri
类型,从而检查它以什么结尾:
request-uri
- Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request
否定先行 (?!.*\.(?:jpg|png|css|js)$)
实际上会检查 URI 是否未以非捕获组中列出的任何扩展名结尾。您可以在 |
符号后添加更多要排除的扩展名。