APACHE 比较复杂的虚拟主机

APACHE 比较复杂的虚拟主机

NameVirtualHost 192.168.0.193:80
NameVirtualHost 192.168.0.193:8080
NameVirtualHost 192.168.0.194:80
NameVirtualHost 192.168.0.194:8080

<VirtualHost 192.168.0.193:80>
    DocumentRoot /www/default/ip3/80
    ServerName 192.168.0.193
</VirtualHost>

<VirtualHost 192.168.0.193:8080>
    DocumentRoot /www/default/ip3/8080
    ServerName 192.168.0.193
</VirtualHost>

<VirtualHost 192.168.0.194:80>
    DocumentRoot /www/default/ip4/80
    ServerName 192.168.0.194
</VirtualHost>

<VirtualHost 192.168.0.194:8080>
    DocumentRoot /www/default/ip4/8080
    ServerName 192.168.0.194
</VirtualHost>

<VirtualHost 192.168.0.194:80>
    DocumentRoot /www/mail/80
    ServerName mail.com
    ErrorLog logs/mail_log
    CustomLog logs/access_mail_log common
</VirtualHost>

<VirtualHost 192.168.0.194:8080>
    DocumentRoot /www/mail/8080
    ServerName mail.com
    ErrorLog logs/mail_log
    CustomLog logs/access_mail_log common
</VirtualHost>

<VirtualHost 192.168.0.193:80>
    DocumentRoot /www/news/80
    ServerName news.com
    ErrorLog logs/news_log
    CustomLog logs/access_news_log common
</VirtualHost>

<VirtualHost 192.168.0.193:8080>
    DocumentRoot /www/news/8080
    ServerName news.com
    ErrorLog logs/news_log
    CustomLog logs/access_news_log common
</VirtualHost>

<VirtualHost _default_:*>
    DocumentRoot /www/default
</VirtualHost>
Listen 192.168.0.193:80
Listen 192.168.0.193:8080
Listen 192.168.0.194:80
Listen 192.168.0.194:8080


主要是针对多IP 多端口的虚拟主机  现在基本功能都可以实现   

现在有一个情况  如果用户使用一个未被配置的域名访问主机

或直接用IP地址访问  都会指向default里的目录

因为匹配不到虚拟主机 会用默认的第一个出现的主机

我想问一下 如何吧IP访问和未被配置的域名访问分隔开来
建议楼主试试用rewritecond+rewriterule重写URL请求.
http://man.chinaunix.net/newsoft ... od/mod_rewrite.html