.htaccess重定向更改URL

时间:2012-04-15 15:30:14

标签: apache .htaccess mod-rewrite web

我希望将example.com/foo/[some string]FOOBAR重定向到subdomain.example.com/[some string]Foobar

我在我的.htaccess文件中使用     RedirectMatch 301 /foo/(^.*$)FOOBAR http://subdomain.example.com/$1Foobar 哪个不起作用,只会导致404

有什么建议吗?

1 个答案:

答案 0 :(得分:2)

最有可能的原因是你有以下规则:

RedirectMatch 301 /foo/(^.*$)FOOBAR http://subdomain.example.com/$1Foobar

在哪里,您已将$放在括号内!请尝试以下方法:

RedirectMatch 301 /foo/(^.*)FOOBAR$ http://subdomain.example.com/$1Foobar