【问题标题】:404 - File or directory not found. vuejs 3 and plesk404 - 找不到文件或目录。 vuejs 3 和 plesk
【发布时间】:2023-04-11 05:05:02
【问题描述】:

我用 Vuejs 开发了一个 SPA,并在 Plesk 服务器上发布了 "dist" 文件夹。但是当我刷新任何路线时,它会在浏览器上显示 “404 - 找不到文件或目录”

我在根目录中包含 .htaccess 文件,内容来自History mode - vuejs documentation,但没有运气:(

我的 .htaccess 文件如下所示。

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.html [L]
</IfModule>

我也尝试过this 解决方案,但它并没有解决我的问题。请帮忙。

【问题讨论】:

    标签: vue.js plesk


    【解决方案1】:

    您应该将其添加到您的 .htaccess 文件中

    <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /
      RewriteRule ^index\.html$ - [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.html [L]
    </IfModule>
    

    https://router.vuejs.org/guide/essentials/history-mode.html#apache

    【讨论】:

    • 非常感谢您的回复。但这对我不起作用
    猜你喜欢
    • 1970-01-01
    • 2020-02-25
    • 1970-01-01
    • 1970-01-01
    • 2019-07-18
    • 2014-11-28
    • 1970-01-01
    • 2019-10-15
    • 2021-01-31
    相关资源
    最近更新 更多