Advertisement
thesuhu

Angular Apache

Nov 3rd, 2020
2,180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.00 KB | None | 0 0
  1. # Cloned complete project repository on my server.
  2. # Installed dependencies using
  3. npm install.
  4. # Build using command and it created a dist directory.
  5. ng build --prod
  6. # Changed apache root to /var/www/html/dist directory.
  7. # Enabled mod_rewrite, restarted apache and added this .htaccess in my dist directory.
  8.  <IfModule mod_rewrite.c>
  9.   RewriteEngine On
  10.   RewriteBase /
  11.   RewriteRule ^index\.html$ - [L]
  12.   RewriteCond %{REQUEST_FILENAME} !-f
  13.   RewriteCond %{REQUEST_FILENAME} !-d
  14.   RewriteRule . /index.html [L]
  15. </IfModule>
  16.  
  17. # jika di htdoc/www di dalam sub direktori sbb:
  18. # To host in a sub directory with apache, you can just do this:
  19. # Build command similar to this:
  20. ng build --base-href /myapp/
  21. # atau
  22. ng build --prod --configuration production --base-href /myapp/
  23. # .htaccess file would look like this
  24. RewriteEngine On
  25. RewriteBase /myapp/
  26. Options +FollowSymLinks
  27.  
  28. RewriteCond %{REQUEST_FILENAME} !-f
  29. RewriteRule ^(.*)$ index.html [L,QSA]
  30.  
  31. # note:
  32. # .htaccess ditaruh di root htdoc/www
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement