This is the original I need to modify:

https://example.com/actualites-cyclisme/criterium-du-dauphine/5115-dauphine-libere-le-parcours-devoile-lalpe-dhuez-fait-son-retour

These are the things I have done (which is what I wanted!)

https://example.com/dauphine-libere-le-parcours-devoile-lalpe-dhuez-fait-son-retour/

But… I want to include a condition, for example I do not want theses URLs to be touched:

https://example.com/123456-dauphine-libere-le-parcours-devoile-lalpe-dhuez-fait-son-retour/

https://example.com/aaaaaa-123456-dauphine-libere-le-parcours-devoile-lalpe-dhuez-fait-son-retour/

Here’s my Awesome regex :

RewriteRule /?(.*)([0-9]+)-(.*)$  /$3 [R=301,L]

I probably have to say that I NEED /(.*)/0000-post, but if I add a slash within the regex it does not work anymore.

I used http://htaccess.mwl.be btw.

1 Answer
1

Could help some WordPress user who want to not get 404 when changing permalinks.

# You dont want your medias to be rewritten
RewriteCond %{REQUEST_URI} !^/(wp-content/uploads)/

RewriteRule /?(.*)(/)([0-9]+)-(.*)$  /$4 [R=301,L]

Leave a Reply

Your email address will not be published. Required fields are marked *