问题描述
限时送ChatGPT账号..我刚刚在 Ubuntu 12.04 中设置了 apache/php/mysql,并为我的虚拟目录创建了一个别名,这是我的/etc/apache2/sites-enabled/000-default 文件:
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>
请注意,我已经将 chown 和 chmod 应用到:/home/czetsuya/projects/eclipse/eclipse-php/demo-portfolio
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
但是当我访问:_http://localhost/demo 时,出现 404 Not found 错误.查看/var/log/apache2/error.log 我发现它仍然指向/var/www/demo:
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?
请注意,我已经重新启动并重新加载了 apache2.并且还启用了重写.
Note that I already restart and reload apache2. And rewrite is also enabled.
谢谢,
切苏亚
Thanks,
czetsuya
推荐答案
您的问题很可能可以通过 mod_alias 手册;
Your problem can most likely be solved by the mod_alias manual;
请注意,如果您在 URL 路径中包含尾随/则服务器将需要尾随/以扩展别名.也就是说,如果你用
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
别名/icons//usr/local/apache/icons/那么 URL/icons 将不会是别名,因为它缺少尾随/.
Alias /icons/ /usr/local/apache/icons/ then the URL /icons will not be aliased, as it lacks that trailing /.
尝试将别名中的 /demo/
更改为 /demo
,这样效果会更好.
Try changing /demo/
to /demo
in your alias, and it should work better.
这篇关于Apache2 别名在 Ubuntu 中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论