Skip to content

Instantly share code, notes, and snippets.

@amnek0
Forked from lukehedger/htaccess-extension-remover
Last active August 29, 2015 14:24
Show Gist options
  • Save amnek0/a4fc27092be4749c4a82 to your computer and use it in GitHub Desktop.
Save amnek0/a4fc27092be4749c4a82 to your computer and use it in GitHub Desktop.

Revisions

  1. @lukehedger lukehedger created this gist Jun 5, 2014.
    26 changes: 26 additions & 0 deletions htaccess-extension-remover
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    # ----------------------------------------------
    # Quick method:
    # ----------------------------------------------

    Options +MultiViews

    # With Apache MultiViews, the server will look for files that match the requested resource (eg. a request for "site.com/page" will serve "site.com/page.php")

    # ----------------------------------------------
    # Long method:
    # ----------------------------------------------

    Options +FollowSymLinks
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.html -f
    RewriteRule ^(.+)$ $1.html [L,QSA]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^(.+)$ $1.php [L,QSA]

    # You'll need a RewriteCond/Rule set per file type