I have an Angular app on a LAMP stack that loads as a WordPress theme like this in the themes/XXX/index.php:
<?php
include_once "index.html";
This loads fine when going to the root URL example.com
However, I need to redirect all routes to index.html so that the angular app will resolve on any route. example.com/abc will give me a 404 error.
WordPress location: /var/www/html
my /etc/apache2/sites-enabled/example_com.conf looks like this:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =example.com [OR]
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
<Directory "/var/www/html">
AllowOverride All
</Directory>
</VirtualHost>
/var/www/html/.htaccess looks like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Changing the .htaccess file to anything, or even removing it doesn't seem to do anything.
How can I redirect any 404 so that the angular app will resolve?