Skip to content

Instantly share code, notes, and snippets.

@PatrickMurphy
Created September 19, 2017 16:33
Show Gist options
  • Save PatrickMurphy/8186f072386e0a556de3eead53e80aac to your computer and use it in GitHub Desktop.
Save PatrickMurphy/8186f072386e0a556de3eead53e80aac to your computer and use it in GitHub Desktop.
HtAccess Redirect example
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^api/v1/([^/]*)/([^/]*)/([^/]*)$ api/router.php?endpoint=$1&verb=$2&id=$3 [QSA,NC,L]
RewriteRule ^api/v1/([^/]*)/([^/]*)$ api/router.php?endpoint=$1&verb=$2 [QSA,NC,L]
RewriteRule ^api/v1/([^/]*)$ api/router.php?endpoint=$1 [QSA,NC,L]
RewriteCond %{THE_REQUEST} \s/+(sidebar)\.php[\s?] [NC]
RewriteRule ^ /%1 [R=301,L,NE]
RewriteRule ^(sidebar).png?$ $1.php [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^sitemap\.xml$ sitemap.php [L]
RewriteRule ^sitemap$ sitemap.php [L]
RewriteRule ^crime/([^/]*)/$ /crime.html?id=$1 [L]
RewriteRule ^crime/([^/]*)$ /crime.html?id=$1 [L]
RewriteRule ^team/([^/]*)/$ /team.html?id=$1 [L]
RewriteRule ^team/([^/]*)$ /team.html?id=$1 [L]
RewriteRule ^player/([^/]*)/$ /player.html?id=$1 [L]
RewriteRule ^player/([^/]*)$ /player.html?id=$1 [L]
RewriteRule ^position/([^/]*)/$ /position.html?id=$1 [L]
RewriteRule ^position/([^/]*)$ /position.html?id=$1 [L]
</IfModule>
#Create filter to match files you want to cache
<Files *.js>
Header add "Cache-Control" "max-age=604800"
</Files>
<Files *.css>
Header add "Cache-Control" "max-age=604800"
</Files>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment