I am using React Router (React app in a home page) with WordPress.
The problem is when a user first loads a page with client URL route, for example site . com/recommendations
, they see a 404 error.
I can't redirect a user, because in this case the URL will be changed, too.
I know, I can do it if I change .htaccess
, but I want to be dynamic.
What I did for now:
function i_redirect() {
add_rewrite_rule( '^recommendations', "index.php", 'top' );
}
add_action('init', 'i_redirect');
But still shows 404, if I access /recommendations
.