I hosted my Nuxt 3 project at https://nuxt-deploy.mpetrosyan.com. When navigating from the main page to a post page, everything works fine. However, if I refresh the page while on a post (e.g., https://nuxt-deploy.mpetrosyan.com/posts), I get a 404 error.
I use npm run generate to build the project.
My app directory looks like this:
nuxt-deploy/
├── .htaccess
├── dist/
Here is my .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !dist/
RewriteRule (.*) /dist/$1 [L]
RewriteRule ^distindex.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /dist/index.html [L]
</IfModule>
I don’t have direct access to the Apache configuration. If I move all the files from the dist folder to the root folder, everything works, but I want to avoid this. How can I configure my setup to handle page refreshes correctly without moving the files?
Miqayel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.