Skip to content

Instantly share code, notes, and snippets.

@blacknoob20
Forked from ardani/.htaccess
Created August 27, 2021 20:59
Show Gist options
  • Save blacknoob20/c016be4aa662bb027e3c4ddacad41262 to your computer and use it in GitHub Desktop.
Save blacknoob20/c016be4aa662bb027e3c4ddacad41262 to your computer and use it in GitHub Desktop.

Revisions

  1. @ardani ardani created this gist Mar 30, 2016.
    27 changes: 27 additions & 0 deletions .htaccess
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    <IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
    Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
    RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    # Always set these headers.
    Header always set Access-Control-Allow-Origin "*"
    Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
    Header always set Access-Control-Max-Age "1000"
    Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"

    # Added a rewrite to respond with a 200 SUCCESS on every OPTIONS request.
    RewriteCond %{REQUEST_METHOD} OPTIONS
    RewriteRule ^(.*)$ $1 [R=200,L]
    </IfModule>