skip to Main Content

In dev version it works good. But when I make production, throw it to host via apache and trying to enter to internal pages (non-main page ‘/’) by path or by reload page it give 404 error. It is pretty logical because we haven’t static files like ‘user.html’ or smth like that. How to make router generate all static files?

404

2

Answers


  1. Chosen as BEST ANSWER
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.html
    

    Insert that in .htaccess file


  2. !!!!! HOT HINT FROM:
    Vue Router return 404 when revisit to the url

    First you need to:
    !!!!!!!!!!!!!!!!!!!!!!
    sudo a2enmod rewrite
    !!!!!!!!!!!!!!!!!!!!!

    Then, add the following block to /etc/apache2/apache2.conf:

    <Directory /var/www/html/>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index.html$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.html [L]

    After this, do

    sudo systemctl restart apache2

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search