Vue 3 App in Wordpress - Best way to handle HTML5 Mode Routing (createWebHistory)

Viewed 128

I have built a Vue app that is deployed within a Wordpress Page on a Wordpress site and it works really well.

However I have one issue that I am trying to solve.

The app runs on the a url something like this

https://www.examplesite.com/vue-app

Since the router history mode is set to history: createWebHashHistory() the url shows as follows

https://www.examplesite.com/vue-app/#/

Routed pages something like this

https://www.examplesite.com/vue-app/#/style/123

When I set history mode to createWebHistory() to use HTML5 Routing in Vue I encounter an issue. The page routes to the 404 page of my Vue app and trying to access a routed page gives a server 404

I understand why this is happening and that I need to setup some rewrite rules on the server to handle this but I have no idea how.

Has anyone else had to do this before and any ideas how?

0 Answers
Related