Skip to content

Instantly share code, notes, and snippets.

@rozsazoltan
Last active December 10, 2022 10:16
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/9bf6e66331a98ce2976f58565f9afbc8 to your computer and use it in GitHub Desktop.
Save rozsazoltan/9bf6e66331a98ce2976f58565f9afbc8 to your computer and use it in GitHub Desktop.
All request redirect to index.php (important in OOP PHP application)

Important for PHP applications

# 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.php
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^ index.php [L]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment