I have two domains.
farrwest.com (running vuestore on port 3000 and vuestore-api on 8080)
and
dev.farrwest.com (running vuestore on port 3001)
I have added .htaccess
with rewrite rules on both domains root directory.
With the following configuration.
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]
Both of the sites load fine, except, before loading they goes to 404 page not found, then the page is loaded.
I would have gone for reverseproxy on apache virtualhost, but i could not find the configuration for it in cpanel.
And with htaccess i tried to find a way around, but have not found any solution to this problem.
Found Solution:
Updated my .htaccess files as following.
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]