htaccess rewrite rule with regular expression

后端 未结 1 615
粉色の甜心
粉色の甜心 2021-01-24 10:33

I have a hard time to create rewrite rule for a redirect using part of an old URL. Example:

Old URL: http://www.example.com/news/index.php/2014/11/07/my-blog-post-from-o

相关标签:
1条回答
  • 2021-01-24 10:43

    Just match for the blocks until hyphen (-) is encountered:

    RewriteRule ^news/index\.php/([^-]+-[^-]+-[^-]+).* /$1 [R=301,L,NC]
    
    0 讨论(0)
提交回复
热议问题