2

我有一个这样的网址:

/anycharsinsidehere/hello-this-is-a-page-to-redirect.html

我想将它重定向到这样的静态页面:

Redirect 301 /*/hello-this-is-a-page-to-redirect.html http://www.site.com/new-page-redirected.html

我怎样才能得到这个?

我需要匹配,例如:

/dh48hsi3t8y/hello-this-is-a-page-to-redirect.html
/fnf;d3thgB/hello-this-is-a-page-to-redirect.html
/fkhg84HFB/hello-this-is-a-page-to-redirect.html
/nefjb398tFfeihg/hello-this-is-a-page-to-redirect.html

等等

4

2 回答 2

1

要使用正则表达式支持,您需要使用RedirectMatch而不是Redirect

RedirectMatch 301 ^/[^/]+/hello-this-is-a-page-to-redirect\.html$ http://www.site.com/new-page-redirected.html
于 2013-10-15T14:45:14.083 回答
1

使用 mod_alias,您需要RedirectMatch的不仅仅是Redirect

RedirectMatch 301 ^/(.*)/hello-this-is-a-page-to-redirect.html http://www.site.com/new-page-redirected.html

使用 mod_rewrite:

RewriteEngine On
RewriteRule ^(.*)/hello-this-is-a-page-to-redirect.html http://www.site.com/new-page-redirected.html [L,R=301]
于 2013-10-15T14:45:35.940 回答