Last active
August 28, 2022 13:08
-
-
Save MPrtenjak/7ce72b4ec03fb0191484a649f38d29c4 to your computer and use it in GitHub Desktop.
Apache .htaccess file for running Blazor Web App
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<IfModule mod_headers.c> | |
# Serve brotli compressed files if they exist and the client accepts brotli. | |
RewriteCond "%{HTTP:Accept-encoding}" "br" | |
RewriteCond "%{REQUEST_FILENAME}\.br" "-s" | |
RewriteRule "^(.*)\.(js|json|css|dll|dat|blat|wasm)$" "$1\.$2\.br" [QSA] | |
# Serve gzip compressed files if they exist and the client accepts gzip. | |
RewriteCond "%{HTTP:Accept-encoding}" "gz" | |
RewriteCond "%{REQUEST_FILENAME}\.gz" "-s" | |
RewriteRule "^(.*)\.(js|json|css|dll|dat|blat|wasm)$" "$1\.$2\.gz" [QSA] | |
# Serve correct content types, and prevent double compression. | |
RewriteRule "\.css\.br$" "-" [T=text/css,E=no-brotli:1] | |
RewriteRule "\.js\.br$" "-" [T=text/javascript,E=no-brotli:1] | |
RewriteRule "\.json\.br$" "-" [T=application/json,E=no-brotli:1] | |
RewriteRule "\.dll\.br$" "-" [T=T=application/octet-stream,E=no-brotli:1] | |
RewriteRule "\.dat\.br$" "-" [T=application/octet-stream,E=no-brotli:1] | |
RewriteRule "\.blat\.br$" "-" [T=application/octet-stream,E=no-brotli:1] | |
RewriteRule "\.wasm\.br$" "-" [T=application/wasm,E=no-brotli:1] | |
# Serve correct content types, and prevent double compression. | |
RewriteRule "\.css\.gz$" "-" [T=text/css,E=no-gzip:1] | |
RewriteRule "\.js\.gz$" "-" [T=text/javascript,E=no-gzip:1] | |
RewriteRule "\.json\.gz$" "-" [T=application/json,E=no-gzip:1] | |
RewriteRule "\.dll\.gz$" "-" [T=T=application/octet-stream,E=no-gzip:1] | |
RewriteRule "\.dat\.gz$" "-" [T=application/octet-stream,E=no-gzip:1] | |
RewriteRule "\.blat\.gz$" "-" [T=application/octet-stream,E=no-gzip:1] | |
RewriteRule "\.wasm\.gz$" "-" [T=application/wasm,E=no-gzip:1] | |
<FilesMatch "(\.js\.br|\.css\.br|\.json\.br|\.dll\.br|\.dat\.br|\.blat\.br|\.wasm\.br)$"> | |
# Serve correct encoding type. | |
Header set Content-Encoding br | |
# Force proxies to cache brotli & non-brotli | |
Header append Vary Accept-Encoding | |
</FilesMatch> | |
<FilesMatch "(\.js\.gz|\.css\.gz|\.json\.gz|\.dll\.gz|\.dat\.gz|\.blat\.gz|\.wasm\.gz)$"> | |
# Serve correct encoding type. | |
Header set Content-Encoding gzip | |
# Force proxies to cache gzipped & non-gzipped | |
Header append Vary Accept-Encoding | |
</FilesMatch> | |
</IfModule> | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteBase /sub-directory/ | |
RewriteRule ^index\.html$ - [L] | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule . /sub-directory/index.html [L] | |
</IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just update string 'sub-directory' (2x) with correct directory path of your app on Apache file system