Example-configuration for Angular 5+ with Apache 2.4. Quite simple configuration, really
<VirtualHost *:80>
#-BASIC-CONFIGURATION
ServerName where.ever.com
ServerAdmin [email protected]
DocumentRoot "/progs/apache_instance/htdocs"
#-SERVER-CONFIGURATION
RewriteEngine On
#-DIRECTORY-CONFIGURATION
<Directory "/progs/apache_instance/htdocs">
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
#-LOGGING
CustomLog "|/progs/apache_instance/bin/rotatelogs logs/my-log_log.%Y.%m.%d 86400" common
</VirtualHost>
In order to allow CORS to work as intended, on the same domain, the following stuff can be added as well:
SetEnvIf Origin "^(http(s)?://[a-zA-Z\-0-9]+.wherever.com(:?)([0-9]+)?)$" CORS_ALLOW_ORIGIN=$1
Header always merge Access-Control-Allow-Origin %{CORS_ALLOW_ORIGIN}e env=CORS_ALLOW_ORIGIN
Header always merge Access-Control-Allow-Credentials true env=CORS_ALLOW_ORIGIN
Header always set Vary "Origin"
No issues should appear anymore :-).