{"id":1575,"date":"2022-08-28T14:11:38","date_gmt":"2022-08-28T13:11:38","guid":{"rendered":"https:\/\/www.matjazev.net\/blog\/?p=1575"},"modified":"2022-08-28T14:12:39","modified_gmt":"2022-08-28T13:12:39","slug":"running-blazor-web-app","status":"publish","type":"post","link":"https:\/\/www.matjazev.net\/blog\/2022\/08\/28\/running-blazor-web-app\/","title":{"rendered":"Running Blazor Web App"},"content":{"rendered":"\n<p>My web site is running on Linux\/Apache server. So, I wanted Blazor Web App to run on that server too.<\/p>\n\n\n\n<p>Developing Blazor app was quite easy and straight forward process but writing the right .htaccess file was not so easy. I searched the internet and found sample on Microsoft web pages (<a href=\"https:\/\/docs.microsoft.com\/en-us\/aspnet\/core\/blazor\/host-and-deploy\/?view=aspnetcore-6.0&amp;tabs=visual-studio\">https:\/\/docs.microsoft.com\/en-us\/aspnet\/core\/blazor\/host-and-deploy\/?view=aspnetcore-6.0&amp;tabs=visual-studio<\/a>), but provided .htaccess file sample was not enough.<\/p>\n\n\n\n<p>I think that running Blazor on Apache is interesting for others too, so here is .htaccess file I am using in production (just update string &#8216;sub-directory&#8217; (2x) with correct directory path of your app on Apache file system).<\/p>\n\n\n\n<p>Link to GitHub gist: <a href=\"https:\/\/gist.github.com\/MPrtenjak\/7ce72b4ec03fb0191484a649f38d29c4\">Apache .htaccess file for running Blazor Web App (github.com)<\/a><\/p>\n\n\n\n<pre class=&#8221;wp-block-preformatted&#8221;>&amp;lt;IfModule mod_headers.c&amp;gt;\n&nbsp;&nbsp;&nbsp;&nbsp;# Serve brotli compressed files if they exist and the client accepts brotli.\n&nbsp;&nbsp;&nbsp;&nbsp;RewriteCond &quot;%{HTTP:Accept-encoding}&quot; &quot;br&quot;\n&nbsp;&nbsp;&nbsp;&nbsp;RewriteCond &quot;%{REQUEST_FILENAME}\\.br&quot; &quot;-s&quot;\n&nbsp;&nbsp;&nbsp;&nbsp;RewriteRule &quot;^(.*)\\.(js|json|css|dll|dat|blat|wasm)$&quot; &quot;$1\\.$2\\.br&quot; [QSA]\n\n&nbsp;&nbsp;&nbsp;&nbsp;# Serve gzip compressed files if they exist and the client accepts gzip.\n&nbsp;&nbsp;&nbsp;&nbsp;RewriteCond &quot;%{HTTP:Accept-encoding}&quot; &quot;gz&quot;\n&nbsp;&nbsp;&nbsp;&nbsp;RewriteCond &quot;%{REQUEST_FILENAME}\\.gz&quot; &quot;-s&quot;\n&nbsp;&nbsp;&nbsp;&nbsp;RewriteRule &quot;^(.*)\\.(js|json|css|dll|dat|blat|wasm)$&quot; &quot;$1\\.$2\\.gz&quot; [QSA]\n&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;# Serve correct content types, and prevent double compression.\n&nbsp;&nbsp;&nbsp;&nbsp;RewriteRule &quot;\\.css\\.br$&quot; &quot;-&quot; [T=text\/css,E=no-brotli:1]\n&nbsp;&nbsp;&nbsp;&nbsp;RewriteRule &quot;\\.js\\.br$&quot;&nbsp;&nbsp;&quot;-&quot; [T=text\/javascript,E=no-brotli:1]\n&nbsp;&nbsp;&nbsp;&nbsp;RewriteRule &quot;\\.json\\.br$&quot;&nbsp;&nbsp;&quot;-&quot; [T=application\/json,E=no-brotli:1]\n&nbsp;&nbsp;&nbsp;&nbsp;RewriteRule &quot;\\.dll\\.br$&quot;&nbsp;&nbsp;&quot;-&quot; [T=T=application\/octet-stream,E=no-brotli:1]&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;RewriteRule &quot;\\.dat\\.br$&quot;&nbsp;&nbsp;&quot;-&quot; [T=application\/octet-stream,E=no-brotli:1]&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;RewriteRule &quot;\\.blat\\.br$&quot;&nbsp;&nbsp;&quot;-&quot; [T=application\/octet-stream,E=no-brotli:1]&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;RewriteRule &quot;\\.wasm\\.br$&quot;&nbsp;&nbsp;&quot;-&quot; [T=application\/wasm,E=no-brotli:1]&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;# Serve correct content types, and prevent double compression.\n&nbsp;&nbsp;&nbsp;&nbsp;RewriteRule &quot;\\.css\\.gz$&quot; &quot;-&quot; [T=text\/css,E=no-gzip:1]\n&nbsp;&nbsp;&nbsp;&nbsp;RewriteRule &quot;\\.js\\.gz$&quot;&nbsp;&nbsp;&quot;-&quot; [T=text\/javascript,E=no-gzip:1]\n&nbsp;&nbsp;&nbsp;&nbsp;RewriteRule &quot;\\.json\\.gz$&quot;&nbsp;&nbsp;&quot;-&quot; [T=application\/json,E=no-gzip:1]\n&nbsp;&nbsp;&nbsp;&nbsp;RewriteRule &quot;\\.dll\\.gz$&quot;&nbsp;&nbsp;&quot;-&quot; [T=T=application\/octet-stream,E=no-gzip:1]&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;RewriteRule &quot;\\.dat\\.gz$&quot;&nbsp;&nbsp;&quot;-&quot; [T=application\/octet-stream,E=no-gzip:1]&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;RewriteRule &quot;\\.blat\\.gz$&quot;&nbsp;&nbsp;&quot;-&quot; [T=application\/octet-stream,E=no-gzip:1]&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;RewriteRule &quot;\\.wasm\\.gz$&quot;&nbsp;&nbsp;&quot;-&quot; [T=application\/wasm,E=no-gzip:1]&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&amp;lt;FilesMatch &quot;(\\.js\\.br|\\.css\\.br|\\.json\\.br|\\.dll\\.br|\\.dat\\.br|\\.blat\\.br|\\.wasm\\.br)$&quot;&amp;gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# Serve correct encoding type.\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Header set Content-Encoding br\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# Force proxies to cache brotli &amp;amp; non-brotli\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Header append Vary Accept-Encoding\n&nbsp;&nbsp;&nbsp;&nbsp;&amp;lt;\/FilesMatch&amp;gt;\n&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&amp;lt;FilesMatch &quot;(\\.js\\.gz|\\.css\\.gz|\\.json\\.gz|\\.dll\\.gz|\\.dat\\.gz|\\.blat\\.gz|\\.wasm\\.gz)$&quot;&amp;gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# Serve correct encoding type.\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Header set Content-Encoding gzip\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# Force proxies to cache gzipped &amp;amp; non-gzipped\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Header append Vary Accept-Encoding\n&nbsp;&nbsp;&nbsp;&nbsp;&amp;lt;\/FilesMatch&amp;gt;\n&amp;lt;\/IfModule&amp;gt;\n\n&amp;lt;IfModule mod_rewrite.c&amp;gt;\n&nbsp;&nbsp;RewriteEngine On\n&nbsp;&nbsp;RewriteBase \/sub-directory\/\n&nbsp;&nbsp;RewriteRule ^index\\.html$ - [L]\n&nbsp;&nbsp;RewriteCond %{REQUEST_FILENAME} !-f\n&nbsp;&nbsp;RewriteCond %{REQUEST_FILENAME} !-d\n&nbsp;&nbsp;RewriteRule . \/sub-directory\/index.html [L]\n&amp;lt;\/IfModule&amp;gt;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>My web site is running on Linux\/Apache server. So, I wanted Blazor Web App to run on that server too. Developing Blazor app was quite easy and straight forward process but writing the right .htaccess file was not so easy. I searched the internet and found sample on Microsoft web pages (https:\/\/docs.microsoft.com\/en-us\/aspnet\/core\/blazor\/host-and-deploy\/?view=aspnetcore-6.0&amp;tabs=visual-studio), but provided .htaccess &hellip; <a href=\"https:\/\/www.matjazev.net\/blog\/2022\/08\/28\/running-blazor-web-app\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Running Blazor Web App<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35,34,42],"tags":[60,80,78,81,79],"_links":{"self":[{"href":"https:\/\/www.matjazev.net\/blog\/wp-json\/wp\/v2\/posts\/1575"}],"collection":[{"href":"https:\/\/www.matjazev.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.matjazev.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.matjazev.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.matjazev.net\/blog\/wp-json\/wp\/v2\/comments?post=1575"}],"version-history":[{"count":1,"href":"https:\/\/www.matjazev.net\/blog\/wp-json\/wp\/v2\/posts\/1575\/revisions"}],"predecessor-version":[{"id":1577,"href":"https:\/\/www.matjazev.net\/blog\/wp-json\/wp\/v2\/posts\/1575\/revisions\/1577"}],"wp:attachment":[{"href":"https:\/\/www.matjazev.net\/blog\/wp-json\/wp\/v2\/media?parent=1575"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.matjazev.net\/blog\/wp-json\/wp\/v2\/categories?post=1575"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.matjazev.net\/blog\/wp-json\/wp\/v2\/tags?post=1575"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}