...some existing rules like
Redirect /contact.aspx /offices/ plus some WP generated lines.
Since this is a WordPress site, that is presumably already using mod_rewrite as part of the "front-controller" then you should avoid mixing in mod_alias (
RedirectMatch) redirect directives. Since the two modules run at different times during the request, despite their apparent order in the config file (mod_rewrite runs first) then you can get some unexpected conflicts. At the very least, it is inefficient, since the URL gets rewritten before the mod_alias
Redirect directives should be converted to the "equivalent" mod_rewrite
RewriteRule and placed before the existing WordPress directives. For example, in the case of the above "temporary" redirect from
/offices/, this would be written as:
RewriteRule ^contact\.aspx$ /offices/ [R=302,L]
Note the absent slash prefix on the
If this is intended to be permanent, then change the 302 (temporary) to 301 (permanent) but only once you have confirmed that all is working OK. (Note that the
Redirect directive you posted in the comment is a temporary-302 redirect.)
Then, to redirect all requests for
.aspx files in the
/subdir directory to the subdirectory root, ie.
/subdir/, then you would do the following:
RewriteRule ^(subdir/)[^/]+\.aspx$ /$1 [R=302,L]
(subdir/) - This captures the name of the subdirectory (to save repetition) and is referenced with the
$1 backreference in the substitution.
[^/]+ - This matches 1 or more non-
/ characters. So, any filename, but not a URl-path that contains multiple path segments. ie. It won't match
I should just add, that from an SEO standpoint, redirecting en masse to a common target like this is a bit dubious. It will likely to be seen as a soft-404 in the eyes of Google. And could be confusing for users, unless the target page is in someway related or contains relevant information for the user.