Skip to content

Instantly share code, notes, and snippets.

@shahaj90
Last active March 9, 2024 17:16
Show Gist options
  • Save shahaj90/a3cda7b69106acb3bb4cdb402ead5366 to your computer and use it in GitHub Desktop.
Save shahaj90/a3cda7b69106acb3bb4cdb402ead5366 to your computer and use it in GitHub Desktop.
Nextjs htaccess file for cPanel
<IfModule mod_rewrite.c>
RewriteEngine on
# Remove trailing slash if it exists
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Serve HTML files without extension
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html [NC,L]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment