简体   繁体   中英

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. 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. 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.

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处理-我从数据库中获取所有表达式,然后遍历它们。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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