I need to redirect from:
http://example.com/*/this/any.html
http://example.com/*/*/this/any.html
http://example.com/*/*/*/this/any.html
to:
http://example.com/this/any.html
CodePudding user response:
Try something like the following using mod_rewrite at the top of the root .htaccess
file:
RewriteEngine On
RewriteRule ^(?:[^/] /){1,3}(this/[\w-] \.html)$ /$1 [R=302,L]
any.html
- the file basename (any
) is permitted to contain the following characters: a-z
, A-Z
, 0-9
, _
(underscore) and -
(hypen)