【发布时间】:2018-11-15 15:39:53
【问题描述】:
我需要使用 RedirectMatch 重定向所有以特定单词开头的 URL。
假设我需要重定向任何以关键字“pdf”开头的 URL,都应该重定向到基本 URL。
要求:
http://www.example.com/pdf -> http://www.example.com/
http://www.example.com/pdf-444-abc -> http://www.example.com/
http://www.example.com/blog/pdf-abc-1234 -> must not redirect
http://www.example.com/images/web/pdf/1234568.jpg -> must not redirect
我使用了以下 301 重定向规则,它重定向了所有上述示例。
RedirectMatch 301 /pdf(.*)$ http://www.example.com/
我怎样才能做到这一点?
【问题讨论】:
标签: .htaccess url url-rewriting url-redirection