title: Nuxt application on Apache Server
body: <p>Good time of the day!  </p>
  
  <p>I'm using statically generated website with <code>npm run generate</code> command, and while all the pages which are placed inside pages directory work just fine (dynamic pages, all implemented functionality, etc), pages which do not exist are simply return the default web server error page.</p>
  
  <p>On local machine with <code>npm run dev</code> i'm able to be forced to the <strong>'Page not found'</strong> error generated by Nuxt, while on the production server running Apache, I can't use middlewares provided by the packages (for example <em>@nuxt/sitemap</em>) as well as any page which may trigger error (40*,5**,3**) is handled directly by the web server.</p>
  
  <p>Since <code>npm run dev</code> just starts the <strong>express</strong> web server, i guess any routing rules put in place by the express could be reproduced in the Apache <strong>.htaccess</strong> config, i just don't know where to look for them.</p>
  
  <p>Here is my configuration from the Vue project <strong>without</strong> Nuxt, where everything works as intended (redirects, etc)</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.html$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.html [L]
  &lt;/IfModule&gt;
  
  # Fonts
  # Add correct content-type for fonts
  AddType application/vnd.ms-fontobject .eot 
  AddType application/x-font-ttf .ttf
  AddType application/x-font-opentype .otf
  AddType application/font-woff .woff
  AddType application/font-woff2 .woff2
  AddType image/svg+xml .svg
  
  ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
  ExpiresByType application/x-font-ttf "access plus 1 year"
  ExpiresByType application/x-font-opentype "access plus 1 year"
  ExpiresByType application/font-woff "access plus 1 year"
  ExpiresByType application/font-woff2 "access plus 1 year"
  ExpiresByType image/svg+xml "access plus 1 year"
  </code></pre>
  
  <p>However, while running the same file on Nuxt application, every request just redirected back to the home page.</p>
  
  <p>This is how the router configured in the <strong>nuxt.config.js</strong></p>
  
  <pre><code>router: {
      mode: 'history',
      middleware: [
        'i18n',
        'check-auth'
      ]
  }
  </code></pre>
  
  <p>So from my point of view, i've provided web server with information it needs to properly identify when the page does not exists (inside the application), but instead of trying to do so, it simply checks whether the file exists physically.</p>