0

I have a bunch of URLs counting to thousands i need to redirect and there are thre main patterns in URL

first pattern There is a dash - starting the title url and want to remove that dash e..g

www.example.com/buzz/news/the-written--malice-of-rdicile www.example.com/buzz/news/the-written-malice-of-rdicile

www.example.com/break/news/5-kids--were-found-rigmaroling-armed  www.example.com/break/news/5-kids-were-found-rigmaroling-armed

second pattern

There are two dashes -- in between urls that need to be changed to just one dash - e..g

www.example.com/buzz/news/-the-written-malice-of-rdicile www.example.com/buzz/news/the-written-malice-of-rdicile

www.example.com/break/news/-5-kids-were-found-rigmaroling-armed  www.example.com/break/news/5-kids-were-found-rigmaroling-armed

third pattern There is a dash - ending the title url and want to remove that dash e..g

www.example.com/buzz/news/the-written-malice-of-rdicile- www.example.com/buzz/news/the-written-malice-of-rdicile

www.example.com/break/news/5-kids-were-found-rigmaroling-armed-  www.example.com/break/news/5-kids-were-found-rigmaroling-armed

fourth pattern There is combination of starting dash, double dashes and ending dash in the url and want to remove the starting dash and ending dash and change double dash to single dash e..g

www.example.com/buzz/news/-the-written--malice-of-rdicile- www.example.com/buzz/news/the-written-malice-of-rdicile

www.example.com/break/news/-5-kids-were-found--rigmaroling-armed-  www.example.com/break/news/5-kids-were-found-rigmaroling-armed

www.example.com/break/news/-5-kids-were-found-rigmaroling-armed-  www.example.com/break/news/5-kids-were-found-rigmaroling-armed

There are about 5000 lines of these patterns, so looking for a way to use regex or other means to be able to run through all 5000ish lines and apply the apache rewrite to the URLs

Help will be VERY much appreciated. Thank you in advance

P.S will continue to edit to make question clearer; any question? please ask me.

So altogether, it looks like this LEFT will be the URL to be redirected and RIGHT will the the final URL users need to be on

www.example.com/buzz/news/the-written--malice-of-rdicile www.example.com/buzz/news/the-written-malice-of-rdicile 

www.example.com/break/news/5-kids--were-found-rigmaroling-armed  www.example.com/break/news/5-kids-were-found-rigmaroling-armed

www.example.com/buzz/news/-the-written-malice-of-rdicile www.example.com/buzz/news/the-written-malice-of-rdicile

www.example.com/break/news/-5-kids-were-found-rigmaroling-armed  www.example.com/break/news/5-kids-were-found-rigmaroling-armed

www.example.com/buzz/news/-the-written--malice-of-rdicile- www.example.com/buzz/news/the-written-malice-of-rdicile

www.example.com/break/news/-5-kids-were-found--rigmaroling-armed-  www.example.com/break/news/5-kids-were-found-rigmaroling-armed

www.example.com/break/news/-5-kids-were-found-rigmaroling-armed-  www.example.com/break/news/5-kids-were-found-rigmaroling-armed
  • You need to proof/fact check your examples; examples 1 and 2 (stopped reading at that point) do not match the patterns you describe. Presumably, you have them back to front... – jasonwryan Feb 24 '16 at 2:01
0

It ended up that i had matching source and destination URLs and did not need to use regex to simplify or do any optimization.

So just did it line by line, so 5000ish line redirects..yes i know

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.