商店 |访问 |页面在加载前转到 404

问题描述

我有两个域。

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 我试图找到解决方法,但没有找到任何解决此问题的方法

解决方法

找到解决方案:

更新了我的 .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]

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...