I need to redirect an old domain to a new domain, and while I'm at it, I'd like to move from using + as the spacer, to using - instead. I know it's pretty simple, but I'm banging my head against the wall here.
It's doable with regex, but are you sure that the old domain doesn't have urls with '+' that aren't spacers?
Absolutely positive. All OLD urls are old.olddomain.com/searchterm or old.olddomain.com/search+term, no spaces. I've already done the redirect with a PHP 301, but if anyone can give me an htaccess solution it would be good.
I think it's way better to deal with this on a php level. All I got with regex is a series of 301 redirects for every character changed (3 redirects if there are 3 +'s within url, and so on). There is perhaps some more elegant way to deal with it, but it is even more elegant with simple php code str_replace('+', '-', $_SERVER['QUERY_STRING']). This way you also don't need to worry about infinite 301 loops.
Yeah that's what I ended up doing a few days ago. I've got a massive learning difficulty with htacess + regex. If I can do it with PHP instead, I usually do