Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@rozsazoltan
Last active December 10, 2022 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rozsazoltan/d010f615e5be75aeb3f13dcfccbbae1e to your computer and use it in GitHub Desktop.
Save rozsazoltan/d010f615e5be75aeb3f13dcfccbbae1e to your computer and use it in GitHub Desktop.
All request redirect to index.html (important in JavaScript applications - Vue, React, Preact, Svelte, ...)

Important for JavaScript frameworks: Vue, React, Preact, Svelte, ...

# If mod_rewrite.c is enabled
<IfModule mod_rewrite.c>
  # Enable Rewrite Engine
  RewriteEngine On

  # Redirect closing-slash requests if not a folder
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} (.+)/$
  RewriteRule ^ %1 [L,R=301]

  # All request redirect to ./index.html
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^ index.html [L]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment