简体   繁体   中英

PHP regexp - find all URLs except special folders in URI

Need to get all URLs like:

http://domain.name/novostroyki/novyy_petergof/

http://domain.name/novostroyki/novyy_petergof/?var1=value1&val2=value2=...

but not the following ones:

http://domain.name/novostroyki/novyy_petergof/flats/

http://domain.name/novostroyki/novyy_petergof/flats/?var1=value1&val2=value2=...

Tried something like that, but it doesn't work as I wish:

/novostroyki/((?!flats)[a-z_0-9A-Z\.])*/?\??(.*)/

Try this regex:

/novostroyki/((?!flats)[\w.]*/?)*(\?.*)?

Not sure if it will be fine in all cases - it certainly should be in the ones listed above.

check if this suggestion is true:

if an url matches the regex on the list, it doesn't continue to the next item on the list.

then you can use:

the regex with all novostroyki after the regex with all novostroyki/flats/

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