【发布时间】:2012-01-21 19:13:50
【问题描述】:
我的.htaccess 文件如下所示:
RewriteEngine On
RewriteRule ^articles/(\d+)*$ ./articles.php?id=$1
因此,如果请求 URL foo.com/articles/123,则控制权转移到 articles.php?id=123。
但是,如果请求的 URL 是:
foo.com/articles/123/
或
foo.com/articles/123/whatever
我收到“404 Not Found”响应。
在所有这些情况下,我都想致电articles.php?id=123。所以,如果 URL 以foo.com/articles/[digits]... 开头,不管数字后面有什么其他字符,我都想执行articles.php?id=[digits]。 (URL 的其余部分被丢弃。)
我必须如何更改正则表达式才能实现这一点?
【问题讨论】:
标签: php url mod-rewrite