Just stumbled upon the WordPress Redirection plugin at work and as usual I’m going to give a very brief and incomplete summary of my experience with it.
The interface is lovely but I’m not here to chitchat so I’ll go straight to the technicals.
Originally I figured the redirection matching logic would take the WordPress site url into consideration; thus if your site was located http://www.example.com/wordpress and the redirection was /subpage, I expected it to match http://www.example.com/wordpress/subpage but it didn’t. It will only match http://www.example.com/subpage.
All right I figured, but can we at least insert a token ala shortcodes which would be replaced with the site url so we can achieve the result above? Nope. I also checked the source code and noticed how the plugin really lacked filters and actions so custom plugins can’t really customize the Redirection plugin in a good way (you can hack it in but then you could never update the plugin).
As a last resort I used regular expressions to achieve the redirects-that-works-out-of-the-box result I wanted. It’s a bit hacky, but will do for now. Let’s say you have two domains: one for local development and one for your production server. They both have different paths, let’s say they’re http://dev/project1 and http://prod (notice how the project is in a subfolder on the development server). Now let’s say you have a path you want to match, f.ex. /some-cool-redirect which redirects to http://coolsite.com.
The regular expression ^\/(project1\/)?my-cool-redirect$ matches both /my-cool-redirect and /project1/my-cool-redirect but importantly not f.ex. /project1/sub/my-cool-redirect.
Update: I see I’m using hyphens in the regex, I think it’s fine as long as they’re outside of square brackets () which are used in character matching but if you want to air on the safe-side add a backslash in front of it to effectively neutralize its meaning (as also done with the slashes).
That’s another case; I’d wish the interface would somehow explain that the URLs are matched only by the query string and not the entire url (includes http and domain etc). It would be more helpful than the user having to guess.
Anyway I could explain the regular expression on demand but cba right now. It’s fairly awesome to learn though but a bit tricky to learn in the start.