4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

VueなどSPAがリロードでNot Foundになる件に対応

Posted at

Vueのアプリでvue-routerを使いSPAにしたとき、
デプロイした環境でブラウザのリロードを行うとNot Foundになる。

image.png

このときHTTPサーバの設定が必要であることをいつも忘れるので記録する。

apacheの場合

sudo vi /etc/httpd/conf/httpd.conf
<VirtualHost *:80>
    ServerName (YourServerName or IP address)
    DocumentRoot /var/www/html
    <Directory "/var/www/html">
        FallbackResource /index.html
    </Directory>
</VirtualHost>
sudo systemctl restart httpd

nginxの場合

sudo vi /etc/nginx/nginx.conf
server {
    listen       80;
    charset      utf-8;

    location / {
        root /usr/share/nginx/html;
        index index.html;
        try_files $uri $uri/ /index.html;
    }
}
sudo systemctl restart nginx

参考

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?