我有这样的网址:
/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
等
答案 0 :(得分:1)
要使用正则表达式支持,您需要使用RedirectMatch
而不是Redirect
:
RedirectMatch 301 ^/[^/]+/hello-this-is-a-page-to-redirect\.html$ http://www.site.com/new-page-redirected.html
答案 1 :(得分: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]