Apache Web Server Aliasing for multiple url giving 404
I am trying to redirect the all the URL starting from /search-engine/* to /var/www/search-engine/dist but the result says not found, I had tried with AliasMatch as shown below
AliasMatch ^/search-engine(.*) /var/www/search-engine/dist
Front-End technology what I am using is Angular. Can any one suggest me where I am missing, I also tried going through many documentation of Apache2.4 but was not able to understand things which would help to reach the result.
Why not simply
Alias "/search-engine" "/var/www/search-engine/dist"
When you want to use AliasMatch
the documentation hints towards:
AliasMatch "^/search-engine(/|$)(.*)" "/var/www/search-engine/dist$1$2"
The first parenthesis match either the file path separator (/
) or the end-of-string.
Next get everything after it. Note that you have to paste these in your directory path with $1
and $2
. This is explained in the documentation:
Alias
will automatically copy any additional part of the URI, past the part that matched, onto the end of the file path on the right side, whileAliasMatch
will not. This means that in almost all cases, you will want the regular expression to match the entire request URI from beginning to end, and to use substitution on the right side.
Update
Check the file permissions of /var/www/search-engine/dist/
. Also check whether you have SELinux or AppArmor or similar running and update those profiles if needed.