I added this rule
RewriteRule ^(.*)-[0-9]+/$ /$1/ [L,QSA]
to remove a trailing number preceded by a hyphen from an url on a WordPress site
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^(.*)-[0-9]+/$ /$1/ [L,QSA]
</IfModule>
But it doesn’t seem to do the trick, to me the regex seems ok but I presume it conflicts with the other rules
You may try this:
The additional 2 lines redirect permanently
http://example.com/any/number/of/folders/anything-NUMBER
To:
http://example.com/any/number/of/folders/anything
The
-NUMBER
combination must be the trailing string in the URL, with or without trailing slash.The hyphen
-
is removed always, even when there is no number. If you want to keep it, replaceRewriteRule .* %1 [R=301,L]
withRewriteRule .* %1- [R=301,L]
Permanent redirection is used to show the substitution URL in the browser’s address bar. For silent mapping, remove
R=301
from [R=301,L].RedirectMatch 301 ^(.*)-[0-9]+/?$ $1/