新手APACHE问题

xt_yxl 2009-05-11 09:14:00
之前一直用IIS,最近准备转向使用APACHE,但是有些问题搞不懂,请教大大

1. APACHE 域名指定:
<VirtualHost localhost:81>  

ServerName www.a.com

DocumentRoot "E:\web\www\a"

</VirtualHost>


如果是一个目录绑定多个域名该怎么写?

2.添加虚拟目录问题:

在 <Directory />处添加
Alias /vdir/ "c:/comexe/"


这个是对所以虚拟主机,还是只针对主站点?
我如何为不同的虚拟主机增加虚拟目录?
...全文
67 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
mengshan1986 2009-05-12
  • 打赏
  • 举报
回复

这是一份完整的虚拟主机配置,如想多加虚拟目录多一行alias即可

NameVirtualHost 10.39.6.59
<VirtualHost 10.39.6.59>
ServerName www.firehare.com
ServerAdmin ubuntu.firehare@gmail.com

DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
# Commented out for Ubuntu
#RedirectMatch ^/$ /apache2-default/
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined
ServerSignature On

Alias /doc/ "/usr/share/doc/"
Alias /do/ "/usr/share/do/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>

mengshan1986 2009-05-11
  • 打赏
  • 举报
回复
.htaccess非常有趣啊,如果只要放在各个站点根目录就可以设置对当前目录一下的所有目录重写的。
xt_yxl 2009-05-11
  • 打赏
  • 举报
回复
太感谢了.
xt_yxl 2009-05-11
  • 打赏
  • 举报
回复
我如果对一个虚拟主机添加多个虚拟目录要怎么写?
mengshan1986 2009-05-11
  • 打赏
  • 举报
回复

可以虚拟主机配置时增加别名,一个主机名是唯一的,别名可以有很多的。虚拟目录可以放在虚拟目录配置里

NameVirtualHost 61.23.12.19:80

<VirtualHost 61.23.12.19:80>
ServerName www.a.com
ServerAlias www.b.com www.c.com www.d.com
DocumentRoot /var/www/html/gaosu/
Alias /vdir/ "c:/comexe/"
</VirtualHost>



xt_yxl 2009-05-11
  • 打赏
  • 举报
回复
URL重写是利用APACHE? 还是用.htaccess文件?

如何设置每个不同站点的htaccess文件?
mrshelly 2009-05-11
  • 打赏
  • 举报
回复
虚拟目录可以添加到 VirtualHost 里,就仅针对该虚拟站点.
<VirtualHost *:81>

ServerName www.a.com
ServerAlias www.b.com

DocumentRoot "E:\web\www\a"

<Directory /vdir "c:/comexe">
</Directory>

</VirtualHost>


24,923

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Apache
社区管理员
  • Apache
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧