【问题标题】:Vuestore | htaccess | page goes to 404 before loading商店 | htaccess |页面在加载前进入 404
【发布时间】:2021-02-14 14:49:23
【问题描述】:

我有两个域。

farrwest.com(在端口 3000 上运行 vuestore,在 8080 上运行 vuestore-api)

dev.farrwest.com(在端口 3001 上运行 vuestore)

我已经在两个域根目录上添加了 .htaccess 和重写规则。

使用以下配置。

farrwest.com:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule  ^api(.*)$  http://localhost:8080/api$1 [P,L]
RewriteRule  ^img/(.*)$  http://localhost:8080/img/$1 [P,L]
RewriteRule (.*) http://localhost:3000/$1 [P,L]

dev.farrwest.com:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} dev.farrwest.com
RewriteRule (.*) http://localhost:3001/$1 [P,L]

两个站点都加载正常,除了在加载之前它们进入 404 页面未找到,然后页面被加载。

我会在 apache 虚拟主机上使用反向代理,但我在 cpanel 中找不到它的配置。

我试图通过 htaccess 找到解决方法,但没有找到任何解决此问题的方法。

【问题讨论】:

    标签: apache vue.js .htaccess vue-storefront


    【解决方案1】:

    找到解决方案:

    更新了我的 .htaccess 文件如下。

    farrwest.com:

    DirectoryIndex
    RewriteEngine On
    RewriteCond %{SERVER_PORT} 80
    RewriteRule  ^api(.*)$  http://localhost:8080/api$1 [P,L]
    RewriteRule  ^img/(.*)$  http://localhost:8080/img/$1 [P,L]
    RewriteRule ^(.*)?$ http://localhost:3000/$1 [P,L]
    

    dev.farrwest.com:

    DirectoryIndex
    RewriteEngine On
    RewriteCond %{SERVER_PORT} 80
    RewriteCond %{HTTP_HOST} dev.farrwest.com
    RewriteRule ^(.*)?$ http://localhost:3001/$1 [P,L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-12
      • 1970-01-01
      • 2016-09-06
      • 1970-01-01
      • 2015-07-16
      • 2017-10-07
      • 1970-01-01
      • 2018-07-01
      相关资源
      最近更新 更多