2

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.

  • Please share the output of the relevant ``ls -lZ`` commands and depending on your OS, the output of ``getenforce`` or ``aa-enabled``. – Tommiie Dec 01 '20 at 11:15

1 Answers1

2

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, while AliasMatch 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.

Tommiie
  • 5,627
  • 2
  • 12
  • 46
  • Hi Tommiie Thank you very much for your reply still after configuring as you mention in your answer it showing 404 only. Is the hyphen in the search-engine creating the problem in AliasMatch. I tried checking for the same but no success . – Prashobh K V Nov 30 '20 at 20:28
  • The hyphen is not a special character in regular expressions, except for example in square brackets to denote a range, e.g. ``[A-Z]``. Did you try the ``Alias`` instead? Why does it have to be ``AliasMatch``? – Tommiie Dec 01 '20 at 11:05
  • Can you please update your question with the current configuration as well as any and all related log messages? – Tommiie Dec 01 '20 at 11:08