我有一个网站与Apache的networking服务器,也承载一些子域名。
我面对的问题是,一旦我激活任何虚拟主机,主站点不断redirect到我(但唯一)的虚拟主机。
如果我停用虚拟主机,一切工作正常在主站点,但没有我需要的子域。
我在ArchLinux下使用apache 2.2.19-1。
我有mydomain.com作为以下httpd.conf的主站点:
ServerRoot "/etc/httpd" Listen 80 #LoadModule section... a lot of LoadModule I omit User http Group http ServerAdmin [email protected] ServerName mydomain.com:80 DocumentRoot "/srv/http" <Directory /> Options FollowSymLinks AllowOverride None Order deny,allow Deny from all </Directory> <Directory "/srv/http"> Options FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> <IfModule dir_module> DirectoryIndex index.html </IfModule> <FilesMatch "^\.ht"> Order allow,deny Deny from all Satisfy All </FilesMatch> ErrorLog "/var/log/httpd/error_log" LogLevel warn <IfModule log_config_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common <IfModule logio_module> # You need to enable mod_logio.c to use %I and %O LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio </IfModule> CustomLog "/var/log/httpd/access_log" combined </IfModule> <IfModule alias_module> ScriptAlias /cgi-bin/ "/srv/http/cgi-bin/" </IfModule> <Directory "/srv/http/cgi-bin"> AllowOverride None Options None Order allow,deny Allow from all </Directory> DefaultType text/plain <IfModule mime_module> TypesConfig conf/mime.types AddType application/x-compress .Z AddType application/x-gzip .gz .tgz </IfModule> # Some included conf files follow, I won't post them, just vhosts, but if needed ask me and I'll post them. As far as I know they aren't relevant # Multi-language error messages Include conf/extra/httpd-multilang-errordoc.conf # Fancy directory listings Include conf/extra/httpd-autoindex.conf # Language settings Include conf/extra/httpd-languages.conf # User home directories Include conf/extra/httpd-userdir.conf # Virtual hosts Include conf/extra/httpd-vhosts.conf # Various default settings Include conf/extra/httpd-default.conf # Secure (SSL/TLS) connections Include conf/extra/httpd-ssl.conf <IfModule ssl_module> SSLRandomSeed startup builtin SSLRandomSeed connect builtin </IfModule>
这是我的conf / extra / httpd-vhosts.conf:
NameVirtualHost *:80 Include conf/extra/vhosts/
最后我conf / extra / vhosts / yetonlyvhost.conf
<VirtualHost *:80> ServerAdmin [email protected] ServerName subdomain.mydomain.com ServerAlias subdomain.mydomain.com DocumentRoot "/home/myuser/subdomaindir" DirectoryIndex indice.html ErrorLog "/var/log/httpd/vhost-error_log" CustomLog "/var/log/httpd/vhost-access_log" combined <Directory "/home/myuser/subdomaindir"> AllowOverride None Order allow,deny Allow from all </Directory> </VirtualHost>
(子域索引必须是文件名'indice.html')
任何想法我做错了什么? 我之前在其他服务器上丢失了一些类似的configuration,但我很确定在这里几乎没问题,但是我现在还没有发现什么问题…
谢谢!
解决scheme非常简单:
对于主要主机也只有另一个虚拟主机。 当Apache被要求一个没有configuration的网站时,它使用默认的,这是虚拟主机列表中的第一个…
谢谢!