0

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]
4

1 回答 1

0

您需要为“面包”之后的所有内容创建捕获组:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^items/([^/]+)/([0-9]+)/?$ /ex/main/item.php?act=view&name=$1&id=$2 [L]
于 2013-08-29T16:56:41.840 回答