可选参数的HTACCESS重写?
我目前正在尝试实现REST API。为此,应调用的URL应为特定格式:
/customer/{customerId}/
- orders/ofers/oferss
/customer/{customerId}/orders/oferers/oferes/stries/{ofiends} < /code>
我得到了使用此重写的变体1和2。
RewriteRule ^customer/([a-zA-Z0-9-]+)/orders/periods/([a-z0-9-]+)?$ api/customer.php?customer_id=$1&period=$2 [L]
现在,应选择添加参数“年”:
3。/customer/{customerId}/orders/ofers/ofers?ear = {year}
我的方法是此规则,但这实际上行不通(至少对于变体2)。
RewriteRule ^customer/([a-zA-Z0-9-]+)/orders/periods([a-zA-Z0-9-]+)?$ api/customer.php?customer_id=$1&year=$2 [L]
有人有想法吗?不幸的是,我对重写规则的了解有限。
提前致谢。
I am currently trying to implement a REST API. For this, the URL to be called should be in a specific format:
/customer/{customerid}/orders/periods
/customer/{customerid}/orders/periods/{period}
I got variants 1 and 2 working with this RewriteRule.
RewriteRule ^customer/([a-zA-Z0-9-]+)/orders/periods/([a-z0-9-]+)?$ api/customer.php?customer_id=$1&period=$2 [L]
Now the parameter "year" should be added optionally:
3. /customer/{customerid}/orders/periods?year={year}
My approach would be this rule, but that doesn't really work (at least not for variant 2).
RewriteRule ^customer/([a-zA-Z0-9-]+)/orders/periods([a-zA-Z0-9-]+)?$ api/customer.php?customer_id=$1&year=$2 [L]
Does anyone have any ideas? My knowledge of Rewrite Rules is unfortunately somewhat limited.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论