我不知道“可选参数”这个词是否正确描述了我的情况。这是我需要的。
我为 URL 重定向编写了以下规则:
RewriteRule ^product/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)$ product/?sid=$2&pid=$3&title=$1&src=$4 [NC,L]
基本上,这将重定向类似
http://localdomain.com/product/Golf-Bats/abc123/def456/stringy
类似于
http://localdomain.com/product/?sid=abc123&pid=def456&title=Golf-Bats&src=stringy
我想要做的是编写一个规则,该规则接受附加/可选/可能无限数量的参数( // 类型构造),但仍重定向到相同的 URL。
这意味着以下 URL:
http://localdomain.com/product/Golf-Bats/abc123/def456/stringy
http://localdomain.com/product/Golf-Bats/abc123/def456/stringy/rand1
http://localdomain.com/product/Golf-Bats/abc123/def456/stringy/rand1/rand2
http://localdomain.com/product/Golf-Bats/abc123/def456/stringy/rand1/rand2/rand3
etc.
都应该指向 URL
http://localdomain.com/product/?sid=abc123&pid=def456&title=Golf-Bats&src=stringy
有任何想法吗?