- Create a
.htaccessfile: Create a file named.htaccessin the root directory of your Next.js application. - Add rewrite rules: Add the following rewrite rules to the
.htaccessfile:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /.next/server/pages/$1 [L]
These rules will redirect any requests that don’t match an existing file or directory to the .next/server/pages directory, where Next.js handles routing.
- Restart Apache: If you’re using Apache as your web server, restart Apache to apply the new rewrite rules.
Once you’ve completed these steps, you should be able to access your page using https://test.jjknowledgebase.com/previewpost without the .next/server/pages part in the URL.