-1

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 ?

MrWhite
  • 43,179
  • 8
  • 60
  • 84
imy sunshine
  • 59
  • 1
  • 2
  • Are you exporting your app as static HTML with `next export`? – juliomalves Oct 12 '21 at 21:01
  • Does this question help... [Nextjs static export redirecting issue](https://stackoverflow.com/questions/69464328/nextjs-static-export-redirecting-issue) – MrWhite Oct 12 '21 at 21:07

1 Answers1

0

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/

  • i've followed exactly what is mentioned in this article , but when i navigate to all the pages (not only refreshing) , it returns to the home page ( my index.js file) ! – imy sunshine Oct 12 '21 at 13:49