用于Apache重写的模式正则表达式

乌贝雷布

我有一堆URL,数以千计的我需要重定向,URL中有三种主要模式

第一种模式-,标题网址以破折号开头,并且想要删除该破折号,例如

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

第四种模式url中包含起始破折号,双破折号和结束破折号的组合,并且要删除起始破折号和结束破折号,并将双破折号更改为单破折号,例如

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

这些模式大约有5000行,因此正在寻找一种使用正则表达式或其他方式来运行所有5000ish行并将apache重写应用于URL的方法。

非常感谢您的帮助。先感谢您

PS将继续进行编辑以使问题更清楚;任何问题?请问我。

因此,总的来说,此LEFT将是要重定向的URL,而RIGHT将是最终用户需要使用的URL

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
乌贝雷布

最后,我有匹配的源URL和目标URL,不需要使用正则表达式来简化或进行任何优化。

所以只是逐行执行,所以5000ish行重定向..是的,我知道

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章