我有两个域名。
farrwest.com (在端口3000上运行vuestore,在8080运行vuestore-api )
和
dev.farrwest.com (在3001端口上运行维斯特尔)
我在两个域的根目录上添加了带有重写规则的.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,我试图找到解决这个问题的方法,但没有找到任何解决办法。
发布于 2021-02-14 15:18:52
找到解决办法:
更新了我的.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]https://stackoverflow.com/questions/66196586
复制相似问题