[Vuejs]-Giving 404 for only '/' route (Nuxt JS) – Shared Hosting Deployment

1πŸ‘

It seems to be a bit late for this answer, but I only found it in github and would like to help anyone who finds this topic with the same problem.

This htaccess is working for me, it loads the index.vue page normally when I refresh and the navigation works.

Replace my-domain with your domain.

RewriteEngine on

# Forcing all incoming requests to HTTPS. 
# HTTPS is required for PWA. If you don't want PWA feature you can deisable next 2 lines

RewriteCond %{HTTP_HOST} ^my-domain.com.br$
RewriteRule "(.*.(jpg|gif|png|svg|js|css|woff2))$" "http://127.0.0.1:3000/$1" [P,NC]
RewriteRule ^(.*) "http://127.0.0.1:3000/$2" [P,L]

0πŸ‘

Use my .htaccess code:

RewriteRule ^index.html.var$ http://127.0.0.1:3000/ [P]
RewriteRule ^(.*) http://127.0.0.1:3000/$1 [P]

This problem has also troubled me for a long time.
I added _index.vue dynamic vue-router and,

validate ({params}) {
  console.log (params.index);
}

The terminal outputs β€œindex.html.var”.
So I was thinking that when we visited the homepage, Apache sent a proxy, but the request URL received by nuxt.js was not β€œ/” but β€œindex.html.var”.

πŸ‘€Sixin Zhou

0πŸ‘

A little late to this party but if anyone is experiencing the same issue, what fixed it for me was to disable DirectoryIndex in .htaccess.

RewriteEngine on

DirectoryIndex disabled
RewriteRule ^(.*) http://127.0.0.1:50000/$1 [P,L]

-1πŸ‘

RewriteEngine on

Forcing all incoming requests to HTTPS.

HTTPS is required for PWA. If you don’t want PWA feature you can deisable next 2 lines

RewriteCond %{HTTP_HOST} ^my-domain.com.br$
RewriteRule β€œ(..(jpg|gif|png|svg|js|css|woff2))$” β€œhttp://127.0.0.1:3000/$1β€³ [P,NC]
RewriteRule ^(.
) β€œhttp://127.0.0.1:3000/$2β€³ [P,L]

Work for me.

Leave a comment