【发布时间】:2011-10-22 04:36:45
【问题描述】:
我不知道“可选参数”这个词是否正确描述了我的情况。这是我需要的。
我为 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。
表示以下网址:
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.
都应该指向网址
http://localdomain.com/product/?sid=abc123&pid=def456&title=Golf-Bats&src=stringy
有什么想法吗?
【问题讨论】:
标签: apache .htaccess mod-rewrite apache2.2