dongzan7016 2013-07-25 14:51
浏览 22
已采纳

正则表达式用于重定向

I'm trying to write a regular expression for a redirect and not having any luck. In this example, an old URL might exist like this:

example.com/about-us/Default.asp

example.com/the-team/Default.asp

Which I want to redirect to:

example.com/about-us/

example.com/the-team/

I've come up with this:

/(\d*)/Default.asp

Which doesn't work...

I've also tried this:

/(\d*)/Default\.asp

As I thought there might be a problem with not having an escape char for the '.', still no luck. Can anyone see what I'm doing wrong?

  • 写回答

2条回答 默认 最新

  • douyan1927 2013-07-25 14:59
    关注

    Got it working thanks to what minitech pointed out:

    /(.*)/Default.asp$
    

    worked a treat! Thanks

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应