问题
I've just setup apache/php/mysql in Ubuntu 12.04, and I've created an Alias for my virtual directory, here's my /etc/apache2/sites-enabled/000-default file:
Alias /demo/ "/home/czetsuya/projects/eclipse/eclipse-php/demo-portfolio"
<Directory "/home/czetsuya/projects/eclipse/eclipse-php/demo-portfolio">
DirectoryIndex index.php
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
Allow from all
</Directory>
Note that I've already applied chown and chmod to: /home/czetsuya/projects/eclipse/eclipse-php/demo-portfolio
chown www-data:www-data /home/czetsuya/projects/eclipse/eclipse-php/demo-portfolio -R
chmow 777 /home/czetsuya/projects/eclipse/eclipse-php/demo-portfolio -R
But when I access: _http://localhost/demo, I got a 404 Not found error. Looking at /var/log/apache2/error.log I found that it's still pointing at /var/www/demo:
File does not exist: /var/www/demo
Any idea why Alias is ignored?
Note that I already restart and reload apache2. And rewrite is also enabled.
Thanks,
czetsuya
回答1:
Your problem can most likely be solved by the mod_alias manual;
Note that if you include a trailing / on the URL-path then the server will require a trailing / in order to expand the alias. That is, if you use
Alias /icons/ /usr/local/apache/icons/ then the URL /icons will not be aliased, as it lacks that trailing /.
Try changing /demo/
to /demo
in your alias, and it should work better.
回答2:
All aliases in Apache 2.4 have to be configured in the /etc/apache2/mods-enabled/alias.conf
file.
They are ignored in the virtual host files.
回答3:
guy take care about exact syntax of these SLASHES it can not be at the end of directory name and also not at the end of alias name, this cost me unbelivable time to find this error, very good work people from apache !!! proper way : Alias "/docs" "/var/web" wrong way: Alias "/docs/" "/var/web/"
来源:https://stackoverflow.com/questions/13189261/apache2-alias-not-working-in-ubuntu