Apache Alias file could not be found
I want to set up an alias in apache like this:
http://example.com/deploy
I do this:
<VirtualHost *:80>
DocumentRoot /var/www/html/
Alias "/deploy/" "/var/www/deploy/"
<Directory "/var/www/deploy/">
Require all granted
</Directory>
</VirtualHost>
Here the folders:
[root@asd]# ls -lisaR /var/www/deploy/
/var/www/deploy/:
total 4
125 0 drwxr-xr-x 2 apache apache 23 Jan 9 13:20 .
8887786 0 drwxr-xr-x 5 root root 47 Jan 9 13:19 ..
148408 4 -rw-r--r-- 1 apache apache 19 Jan 9 13:17 index.php
[root@asd]#
I get always a 404 error. The error says this:
Not Found The requested URL /deploy was not found on this server.
If you are using Apache version 2.4.19 or later you can just write in configuration file:
<VirtualHost *:80>
DocumentRoot /var/www/html/
Alias "/deploy/"
<Directory "/var/www/deploy/">
Require all granted
</Directory>
</VirtualHost>
Also you should verify if mod_alias is enabled, typing sudo a2enmod mod_alias If still doesn't solve your problem you could try to use mod_rewrite:
<VirtualHost *:80>
ServerName undesired.example.com
ServerAlias example.com notthis.example.com
Redirect "/" "http://www.example.com/"
</VirtualHost>
Example source from: https://httpd.apache.org/docs/2.4/rewrite/remapping.html