说到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}
视为字符串,直到我们点击&
字符。这可能吗?如果是这样,怎么办呢?
E.g。 For "id=sdf/sdf/wer/sfd" print_r($_GET['id']) would be "sdf/sdf/wer/sfd"
答案 0 :(得分:0)
最后一行:RewriteRule ^(product)/([^/]+)/? /$1/?id=$2 [L,NC]
应为RewriteRule ^(product)/([^\s]+[^/]+)/? /$1/?id=$2 [L,NC]