Wednesday 15 August 2012

url rewriting - RegEx for URL redirect pattern? -


I need help creating redirects for migrated sites and can use RegEx. This is the first link /cms/events/view/13-03-20/some-post_title.aspx and it is after / event / some-post_title . Anyone know about RegEx patterns that can do this?

If you just need the last part 'will know that the event will always be in front of the URL) Then the following two will work.

It matches all of the one, but there is a slash between the slash and the end of the string.

  var newurl = '/ event /' url.match (/ [^ / /] * $ /);   

There is a replacement version that changes everything up to the last slash.

  var newurl = url.replace (/ (/ | ^) ([^ /] * /) * /, '/ Event /');    

No comments:

Post a Comment