Nextjs dynamic page doesn't appear when refreshing in the server (after build)

989 Views Asked by At

i have a problem in my nextjs application after build ,in the server , i have access to all pages but when i refresh a page with a dynamic path ( page article that is a folder contains a [id].js page , the id is the article title ) this error is shown on the navigator :

Not Found

The requested URL was not found on this server.

Apache/2.4.41 (Ubuntu) Server at myDomain.com Port 80

My .htaccess file contains :

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule (.*)$ $1.html

is there any problem in my htaccess file or i have to configure another file in my app code ?

1

There are 1 best solutions below

1
On

You have a single page app, you entry point is your root file.

You can fix this redirecting all routes to your root file.

https://www.sej-ko.dk/2017/03/29/routing-single-page-application-on-apache-with-htaccess/