Hello,

I've transfered a Statamic v1 website over to version 2 and have some old news and blog posts that have URLs containing . (dots). I'm looking for a way to redirect them to the same URL but with - (hyphens) instead. Example: http://www.example.com/blog/connect2id-server-7.2 -> http://www.example.com/blog/connect2id-server-7-2

I've searched and tried many mod_rewrite solutions (https://stackoverflow.com/questions/38835644/htaccess-replace-spaces-and-dots-with-a-dash) but couldn't get one working without messing up the paths to all the website's assets.

The only example that worked to convert the URL was:

# recursive rule to repeatedly convert DOT or space to hyphen
RewriteRule ^([a-z0-9]+)/([^\s.]*)[.\s]+(.*)$ $1/$2-$3 [NC,DPI,E=DONE:1]

# after all the hyphen conversion is done do a redirect
RewriteCond %{ENV:DONE} =1
RewriteRule ^([0-9a-z]+)/([^\s.]+)$ $1/$2 [R=301,NE,L]

But this stripped the theme's assets (styles, images, etc.)

Any help would be more than welcome!

P.S. I figured out the solution - I had to limit my regex to the /news/ or /blog/ subparts of the URL,

RewriteRule ^(news|blog)/([^.]*)[.]+(.*)$ $1/$2-$3 [NC,DPI,E=DONE:1]

# after all the hyphen conversion is done do a redirect
RewriteCond %{ENV:DONE} =1
RewriteRule ^([0-9a-z]+)/([^\s.]+)$ $1/$2 [R=301,NE,L]