msulibrary/bib-template-journal/master/.htaccess - Htaccess File

msulibrary/bib-template-journal/master/.htaccess

#add handler that allows html, xml, and json to work dynamically as PHP
#https://httpd.apache.org/docs/current/mod/mod_mime.html#addtype
#https://httpd.apache.org/docs/current/mod/mod_mime.html#addhandler
#AddType application/x-httpd-php .html .xml .json
AddHandler php5-script .html .xml .json

#serve all resources labeled as 'text/html' or 'text/plain' with the media type 'charset' parameter set to UTF-8'
#https://httpd.apache.org/docs/current/mod/core.html#adddefaultcharset
AddDefaultCharset utf-8

#serve correct media type (MIME type) for resources
#https://httpd.apache.org/docs/current/mod/mod_mime.html#addtype
AddType application/atom+xml .atom
AddType application/json .json
AddType application/ld+json .jsonld
AddType application/oebps-package+xml .opf
AddType application/rss+xml .rss
AddType application/xml .rdf .xml
AddType application/vnd.ms-fontobject .eot
AddType application/x-font-ttf .ttc .ttf
AddType font/ttf .ttf
AddType font/opentype .otf
AddType font/otf .otf
AddType application/font-woff .woff
AddType font/x-woff .woff
AddType application/font-woff2 .woff2
AddType image/svg+xml .svg
 
#set custom error page for Apache to return
#https://httpd.apache.org/docs/current/mod/core.html#errordocument
ErrorDocument 404 /book/opsis/404.html

#compress html, css, javascript, font, and miscellaneous resources
#https://httpd.apache.org/docs/current/mod/mod_deflate.html
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE "text/css" "text/html" "text/javascript" "text/plain" "text/xml" "application/x-javascript" "application/javascript" "application/json" "application/ld+json" "application/rdf+xml" "application/rss+xml" "application/x-font-woff" "application/x-font-ttf" "application/vnd.ms-fontobject" "font/eot" "font/opentype" "font/otf" "font/ttf" "font/x-woff" "image/bmp" "image/jpeg" "image/svg+xml" "image/vnd.microsoft.icon" "image/x-icon" 
</IfModule>

#remove `ETags` as resources are sent with far-future expires headers
#https://developer.yahoo.com/performance/rules.html#etags
#https://tools.ietf.org/html/rfc7232#section-2.3
#`FileETag None` doesn't work in all cases.
<IfModule mod_headers.c>
  Header unset ETag
</IfModule>

FileETag None

#set expires headers to improve caching
#https://httpd.apache.org/docs/current/mod/mod_expires.html
<IfModule mod_headers.c>
  ExpiresActive on
  ExpiresDefault "access plus 1 month"

  #CSS
  ExpiresByType text/css "access plus 1 year"

  #Data interchange
  ExpiresByType application/atom+xml "access plus 1 hour"
  ExpiresByType application/rdf+xml "access plus 1 hour"
  ExpiresByType application/rss+xml "access plus 1 hour"
  ExpiresByType application/json "access plus 0 seconds"
  ExpiresByType application/ld+json "access plus 0 seconds"

  #Favicon (cannot be renamed!) and cursor images
  ExpiresByType image/vnd.microsoft.icon "access plus 1 week"
  ExpiresByType image/x-icon "access plus 1 week"

  #HTML
  ExpiresByType text/html "access plus 0 seconds"

  #JavaScript
  ExpiresByType application/javascript "access plus 1 year"
  ExpiresByType application/x-javascript "access plus 1 year"
  ExpiresByType text/javascript "access plus 1 year"

  #Media files
  ExpiresByType audio/ogg "access plus 1 month"
  ExpiresByType image/bmp "access plus 1 month"
  ExpiresByType image/gif "access plus 1 month"
  ExpiresByType image/jpeg "access plus 1 month"
  ExpiresByType image/png "access plus 1 month"
  ExpiresByType image/svg+xml "access plus 1 month"
  ExpiresByType image/webp "access plus 1 month"
  ExpiresByType video/mp4 "access plus 1 month"
  ExpiresByType video/ogg "access plus 1 month"
  ExpiresByType video/webm "access plus 1 month"

  #Web Fonts
  #Embedded OpenType (EOT)
  ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
  ExpiresByType font/eot "access plus 1 month"

  #OpenType
  ExpiresByType font/opentype "access plus 1 month"

  #TrueType
  ExpiresByType application/x-font-ttf "access plus 1 month"

  #Web Open Font Format (WOFF) 1.0
  ExpiresByType application/font-woff "access plus 1 month"
  ExpiresByType application/x-font-woff "access plus 1 month"
  ExpiresByType font/woff "access plus 1 month"

  #Web Open Font Format (WOFF) 2.0
  ExpiresByType application/font-woff2 "access plus 1 month" 
</IfModule>

#rewrite rules for URLs and directory patterns
#https://httpd.apache.org/docs/current/mod/mod_rewrite.html#RewriteEngine
#https://httpd.apache.org/docs/current/mod/core.html#options
#https://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase
#https://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriteoptions
<IfModule mod_rewrite.c>
  #Options +FollowSymLinks
  #Options +SymLinksIfOwnerMatch
  RewriteEngine On

  #check for 200 header, legitimate url 
  RewriteCond %{ENV:REDIRECT_STATUS} 200
  RewriteRule .* - [L]

  #change arc.lib.montana.edu/intermountain-journal-science/item.html?id=5 to arc.lib.montana.edu/intermountain-journal-science/item/5
  RewriteBase /book/intermountain-journal-science/
  RewriteRule item/([-_a-zA-Z0-9]+) item.html?id=$1 [L,QSA]

  #remove need to have .html extension in filename
  RewriteCond %{REQUEST_FILENAME}.html -f
  RewriteRule ^(.*)$ $1.html [L,QSA]
</IfModule>

#redirect from the `http://` to the `https://` version of the URL.
#https://wiki.apache.org/httpd/RewriteHTTPToHTTPS

#<IfModule mod_rewrite.c>
#  RewriteEngine On
#  RewriteCond %{HTTPS} !=on
#  RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
#</IfModule>

On Github License

Files

Download PDF of Htaccess file
DEFLATE, ENV, HTTP_HOST, HTTPS, REDIRECT_STATUS, REQUEST_FILENAME

Comments

Apache