0
1

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.

Nuxt3をspaにしてレンタルサーバーで使う

Posted at

さくらのレンタルサーバーに静的サイトとしてデプロイしたかった。

まずconfigを変更.
今回はルートパスが変わるので公開時のルートパスに変更しておく

nuxt.config.ts
export default defineNuxtConfig({
  ssr: false,
  app: {
    baseURL: '/directory-name/'
  },
...

次に静的ファイルを出力する。

terminal
npx nuxi generate  

   
   
するとdistフォルダ内に静的ファイル群ができるので、
それをレンタルサーバーにアップ。

最後に.htaccessを追加してルートパスを合わせる。

.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /directory-name
RewriteRule ^directory-name/index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /directory-name/index.html [L]
</IfModule>
0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?