I'm working on the seed project now
I want to use
nodejs
as api server
listening on port 5001
,
express
as back-end framework,
angularjs
as front-end framework,
and apache
as static file server
(such as lots of .js file that angular requires) listening on port 5000
In angular, I have configuration below
app.config(['$locationProvider', function ($locationProvider) {
$locationProvider.html5Mode(true);
$locationProvider.hashPrefix('!');
}]);
As for apache, I add the following configuration to /etc/apache2/sites-available/000-default.conf
Listen 5000
<VirtualHost *:5000>
DocumentRoot /var/www/seed/public
<Directory /var/www/seed/public >
AllowOverride All
</Directory>
</VirtualHost>
I also add /public/.htaccess
file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# support angular
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) /#!/$1
</IfModule>
The current rewrite rule is for angular, because it needs a hashbang when a user refresh the page
Now I don't know how to redirect api request with URL starting with /api
to port 5001
Is it possible to do this with .htaccess
file?
And is there any better way to cooperate with nodejs, angularjs and apache?
I couldn't find any tutorial about this kind of combination...
Thanks for reading or answering my question