简体   繁体   English

PHP CMS URL模式匹配

[英]PHP CMS URL Pattern Matching

As mentioned in the title, I'm building a CMS and I'm trying to work Patterned URLs into the system. 如标题中所述,我正在构建一个CMS,并且正在尝试将模式化URL应用于系统。 As part of this, Modules can be assigned to a base handle, then have parameters passed to it. 作为其一部分,可以将模块分配给基本句柄,然后将参数传递给它。

Using a regular expression I'd like to match URLs and be able to extract the wildcard information from them. 我想使用正则表达式来匹配URL,并能够从中提取通配符信息。 The general format is below. 常规格式如下。

http://i3network.net/module/
http://i3network.net/module/action/
http://i3network.net/module/action/id/
http://i3network.net/module/action/id/subaction/

I'm currently running this by having 4 regular expressions for each module (that has this feature enabled) are loaded from the database and individually checked. 我目前正在通过从数据库中加载每个模块(启用了此功能)的4个正则表达式来进行运行,并分别进行检查。

The problem that I'm having is that the expressions are matching the first, then not continuing through the order. 我遇到的问题是表达式匹配第一个表达式,然后不继续执行顺序。

This is the expression that I'm using at the moment for the first level. 这是我目前在第一级使用的表达方式。

/^module\//

Any help is greatly appreciated! 任何帮助是极大的赞赏!

我正在使用/^photography$//^photography\\/([a-zA-Z0-9_-])*$//^photography\\/([a-zA-Z0-9_-])*\\/([a-zA-Z0-9_-])*/确认要使用哪个模块(对每个级别都更深的[a-zA-Z0-9_-])*\\/ ,然后/^photography\\/(.*?)//^proofs\\/(.*?)\\/(.*?)/来获得“操作”和“ id” (additionally with another每个子项(additionally with another /(.*?)/`所有这些都用PHP处理-我从数据库中获取所有表达式,然后遍历它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM