Here's my dilemma...
I have a url that looks like this: domain.com/search/x-[something]/y-[something]
I want to redirect anything with /search to /search?param=xyz, while still including the sub-directories. Like /search/x-[something]/y-[something]?param=xyz.
Any advice as to how I can basically wildcard the redirect?
You can try redirecting through the Target inbuilt redirect feature and mention the complete URL with parameters to redirect on
Right but the problem is that the subdirectories in the URL will change. Everything after the /search/ is variable.
So I understand correctly - you are not necessarily wanting to redirect to a completely different page, but basically add a parameters to the same page, and reload?
There are a few ways to achieve this but a short way that might be suitable for your test case is this custom code:
window.location.search += '¶m=xyz';
i see it has been a few weeks since you posted, so hope this helps. I'm unsure if this approach would introduce any reporting concerns but i guess might affect page view numbers if both the initial page and destination page view are recorded.
I think Dave's solution is the right path. You'll want to use a custom code script to handle the redirect rather the the out-of-the-box redirect option per your mentioned criteria.
Your specific use case will require a template rule, an audience, and custom code redirect script.
On step 2 for the targeting you want to create a custom audience that for people who's current page url does NOT contain "param=xyz" to prevent those people from entering a continuous loop.