我正在迁移网站,大多数网页都有页面到第301页重定向 - 没问题。
有一个目录; http://example.com/associates/ 有一大堆个人文件; http://example.com/associates/first-last.php
我需要将它们映射到http://example.com/associates/first-last
我在想RewriteCond /associates/*\.php -f
会找到它们,会重定向它们吗?
答案 0 :(得分:1)
您可以使用以下代码:
RedirectMatch ^/associates/([^.]+)\.php$ /associates/$1
([^。] +)捕获除点之外的任何字符,在您的情况下,它将捕获文件名 first-last 并将其作为$ 1附加到目标网址