使用Apache服务多个目录 [英] Serve multiple directories with Apache

查看:91
本文介绍了使用Apache服务多个目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Ubuntu上运行Apache.我的/var/www文件夹包含两个目录

I am running Apache on Ubuntu. My /var/www folder consists of two directories

/codeigniter
/wordpress

我希望mydomain.com指向/codeigniter,而mydomain.com/blog指向/wordpress.我已经实现了第一个,但是没有达到第二个.

I would like mydomain.com to point to /codeigniter and mydomain.com/blog to point to /wordpress. I have acheived the first one but not the second.

我在site-available/mydomain.com中有以下内容

I have the following in site-available/mydomain.com

<VirtualHost *:80>
  ServerAdmin me@example.com
  ServerName  www.mydomain.com
  ServerAlias mydomain.com

  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.html index.php
  DocumentRoot /var/www/codeigniter/public

  <Directory "/var/www/codeigniter/public">
  Options FollowSymLinks
  AllowOverride All
  Order allow,deny
  Allow from all
  </Directory>
</VirtualHost>

这有效,当我在浏览器中访问mydomain.com时,它将带我到我的codeigniter目录.但是,当我转到mydomain.com/blog时,如何使apache将我带到我的wordpress目录?

This works and when I go to mydomain.com in my browser it takes me to my codeigniter directory. However how can I make apache take me to my wordpress directory when I go to mydomain.com/blog?

推荐答案

简单,在 VirtualHost 块的内部 中添加一个Alias和另一个目录块:

Simple, add an Alias and another directory block inside your VirtualHost block:

Alias /blog/ "/var/www/wordpress/"
<Directory "/var/www/wordpress/">
    ... whatever you want ...
</Directory>

这篇关于使用Apache服务多个目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆