Reputation: 1287
I want to redirect from /web/
or /beta/
to /web/dashboard
or /beta/dashboard/
, respectively.
I tried using as follows ...
<Redirect exact from="/:platform(web|beta)" to="/:platform/dashboard" />
The problem is that when I got to www.abc.com/beta
it simply redirects me to www.abc.com/undefined/dashboard
instead of replacing the :platform
with beta
.
For Reference I'm using the following version: "react-router-dom": "^4.2.2"
Upvotes: 0
Views: 95
Reputation: 1287
One solution that I found works is instead of relying on the params, you can access the location.pathname
prop.
<Redirect exact from="/:platform(web|beta)/" to={`${this.props.location.pathname}/dashboard`}/>
Upvotes: 1