mod rewrite - .htaccess RedirectMatch is OK to remove part from url? -
i want redirect url:
domain.asd/category/node123/attachment/file123 to one:
domain.asd/category/node123 by removing attachment/fn1aa end.
only node123 , file123 dynamic.
the code below working, it's valid, safe , resource-friendly?
redirectmatch permanent category(.*)attachment /category/$1 any recommendation welcome. thx.
try:
redirectmatch permanent ^/category/([^/]+)/attachment /category/$1 it's more strict , won't duplicate forward slashes (/). regex match things this:
domain.asd/foo/something/category/a/b/c/d/e/f/some-attachment by redirecting to:
/category//a/b/c/d/e/f/some- which isn't want do. it's safe , resource friendly using htaccess file (which slight performance hit opposed putting in vhost config).
Comments
Post a Comment