301 Redirect Regex Pattern - Sitecore Redirect module -


i apologize if seems rudimentary question, i'm trying setup redirect pattern 301 module in sitecore , having hard time proper pattern.

i need have following path:

http://www.example.com/some-path/videos/2014/08/08/15/20/some-item-title

converted to: http://www.example.com/some-path/videos/some-item-title

basically strip numerical folders out. how can preserve beginning of path , item name @ end.

an https-safe version appreciated. thanks.

edit:

note, numerical folders in above format: there 4 digit folder, followed four, 2 digit folders.

some-path/whatever/4444/22/22/22/22/item-name

this fit "less global" requirement.

var pattern = @"^(https?://[^/]*/some-path/videos/)\d{4}/\d{2}/\d{2}/\d{2}/\d{2}/(.*)$"; var match = regex.match(myurl, pattern, regexoptions.ignorecase); var rewrittenurl = string.empty; if (match.success) {     rewrittenurl = match.groups[1].value + match.groups[2].value; } 

note chose ignore case. correct behavior given dealing urls. edited original post such pattern match host now.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -