0

谈到 mod_rewrite,我完全是个新手。我的代码:

Options +FollowSymlinks -MultiViews
RewriteBase /

RewriteCond %{THE_REQUEST} ^(GET|HEAD)\s/(product)/\?id=([^\s]+) [NC]
# Strip the query and redirect permanently
RewriteRule  ^(product)  /$1/%3?   [R=301,L,NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{QUERY_STRING} ^$
# Map internally to the original request
RewriteRule  ^(product)/([^/]+)/?  /$1/?id=$2  [L,NC]

它能做什么

example.com/products?id={string}=重写=>example.com/products/{string}其中包含id={string}

问题 它将斜杠视为我不想要的查询字符串的结尾。我希望它被{string}视为一个字符串,直到我们击中一个&字符。这可能吗?如果是这样,如何做到这一点?

例如For "id=sdf/sdf/wer/sfd" print_r($_GET['id']) would be "sdf/sdf/wer/sfd"

4

1 回答 1

0

最后一行:RewriteRule ^(product)/([^/]+)/? /$1/?id=$2 [L,NC]

应该RewriteRule ^(product)/([^\s]+[^/]+)/? /$1/?id=$2 [L,NC]

于 2013-05-05T13:20:09.983 回答