Forum Discussion

mbuk2k_59598's avatar
mbuk2k_59598
Icon for Nimbostratus rankNimbostratus
Aug 29, 2013

Extracting/Removing part of a URI

Hello,

 

Apologies if this has already been asked, however is it possible to extract part of a URI?

 

For example; an incoming URL may be:

 

http://originalurl.com/pages/index.htm/2013/08/15/mypost

 

and we want it to 301 redirect it TO:

 

http://newurl.com/2013/08/15/mypost

 

So we'd want to change the host (which is easy enough), however we want to drop the /pages/index.htm part of the original URI while maintaining anything after that; which in this example is /2013/08/15/mypost

 

Does anyone know if this is even possible?

 

Any guidance would be kindly appreciated.

 

Thank you

 

13 Replies

  • sorry about all the replies, im new at this...

     

    I basically made a list of the 6 different variations they were looking for and repeated everything but the actual word in the directory structure they were looking for.

     

  • now to do a list of different possibilities I would just make a list of them? and make the replaceable part a variable?

    Are you referring to a list of different URI patterns to replace? If so, just add them in pairs to the [string map ] command:

    [string map {"/foo" "" "/bar" ""} [HTTP::uri]]