重写规则以仅检测数字
我正在尝试创建一个重写规则,该规则将仅检测数字并相应地转发它们。我希望如果出现除数字以外的任何内容,则忽略重写规则。
/index.php
- OK/
- OK/42365
- 重写为view.php?id=42365
什么到目前为止我有:
RewriteEngine on
RewriteRule ^([0-9]+)?$ view.php?id=$1 [L]
I am trying to create a rewrite rule which will detect numbers only and forward them accordingly. I want the rewrite rule to be ignored if anything but numbers appears.
/index.php
- OK/
- OK/42365
- rewrites toview.php?id=42365
What I have so far:
RewriteEngine on
RewriteRule ^([0-9]+)?$ view.php?id=$1 [L]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从
([0-9]+)
组末尾删除?
,使其成为可选。您必须有数字才能进行重写:Remove the
?
from the end of the([0-9]+)
group, which makes it optional. You must have numbers for the rewrite to occur: