How to deploy angular2 with Apache server and angular cli?
- ng build --prod
- It will create dist folder in the application
- Copy the dist folder all files to /var/www/html/
- Create .htaccess file in the path of /var/www/html/
- Write this code in .htaccess file
- <IfModule mod_rewrite.c>
- RewriteEngine On RewriteBase / RewriteRule ^index\.html$ - [L]
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_FILENAME} !-d
- RewriteRule . /index.html [L]
- </IfModule>
- sudo service apache2 restart
- <IfModule mod_rewrite.c>
- RewriteEngine On RewriteBase / RewriteRule ^index\.html$ - [L]
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_FILENAME} !-d
- RewriteRule . /index.html [L]
- </IfModule>
Comments
Post a Comment