Reputation: 23
I have an URL like this:
/anycharsinsidehere/hello-this-is-a-page-to-redirect.html
and I want to redirect it to a static page like this:
Redirect 301 /*/hello-this-is-a-page-to-redirect.html http://www.site.com/new-page-redirected.html
How can I obtain this?
I need to match, for example:
/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
etc.
Upvotes: 2
Views: 59
Reputation: 143876
Using mod_alias, you want RedirectMatch
instead of just Redirect
:
RedirectMatch 301 ^/(.*)/hello-this-is-a-page-to-redirect.html http://www.site.com/new-page-redirected.html
Using mod_rewrite:
RewriteEngine On
RewriteRule ^(.*)/hello-this-is-a-page-to-redirect.html http://www.site.com/new-page-redirected.html [L,R=301]
Upvotes: 1
Reputation: 785058
To use regex support you need to use RedirectMatch
instead of Redirect
:
RedirectMatch 301 ^/[^/]+/hello-this-is-a-page-to-redirect\.html$ http://www.site.com/new-page-redirected.html
Upvotes: 1