It's a bit more complicated than that.
The + in the URL has a special meaning. The web server will interpret it as a space. These days it is considered best practices to encode space in its hex form e.g.
http://www.example.com/product.php?productname=Washing%20Machine
which follows RFC 3986 standards, but the + will be around for a long time and is still supported by all browsers and servers.
You want to replace the + with -. You can't do that (even with str_replace) because whereas + means the same thing as space, - doesn't. It just means -.
It is still possible though, but not in PHP. You will need to configure the web server to rewrite any - signs that it sees to spaces before it looks for the file. On Apache you would most likely create a file called .
htaccess
in the root directory of your site and it would contain something like:
RewriteEngine on
# Replace the minus character in incoming URLs with a space.
RewriteRule ^([^-]*)-([^-]*-.*) $1%20$2 [N]
RewriteRule ^([^-]*)-([^-]*)$ /$1%20-$2 [L]