127.0.0.1/ex/main/items/bread
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^items/([^/]+)/?$ /ex/main/item.php?act=view&name=$1 [L]
Works fine
但我如何添加第二条规则?
127.0.0.1/ex/main/items/bread/123/来处理输入和名称
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^items/([^/]+)/?$ /ex/main/item.php?act=view&name=$1&id=$???? [L]
答案 0 :(得分:0)
您需要在“面包”之后为所有内容创建捕获组:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^items/([^/]+)/([0-9]+)/?$ /ex/main/item.php?act=view&name=$1&id=$2 [L]