Expand my Community achievements bar.

How can I redirect to a URL where the sub-directories can be different?


Level 2

Hi all!

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?


4 Replies




You can try redirecting through the Target inbuilt redirect feature and mention the complete URL with parameters to redirect on

Redirect to a URL


Level 2

Right but the problem is that the subdirectories in the URL will change. Everything after the /search/ is variable.


Level 3

Hi Kens,

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?

Instead of trying the in-built redirect feature, this could be done with some simple javascript to add the parameter.

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 += '&param=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.


Employee Advisor

Hi Kens,

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.

  1. Template rule: use OR when page path contains "/search/"
  2. A custom code script (add custom code type modification via modification pane - open with code icon in upper right of editor)
    1. Like Dave suggested:
  3. 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.