url rewriting - React Router with Wordpress

admin2025-06-03  2

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 .

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748911487a314746.html

最新回复(0)