域作为apache中子域的后备

时间:2012-04-26 21:25:18

标签: linux apache ubuntu virtualhost

我的域名中有一些子域名,如果用户写错了子域名,我希望域名可以作为备用域名使用。
这些子域名有效:
files.myadomain.com,phpmyadmin.mydomain.com和server.mydmomain.com

其他域/子域返回HTTP 500错误:

  

由于可能,请求超出了10个内部重定向的限制   配置错误。使用'LimitInternalRecursion'来增加   必要时限制。使用“LogLevel debug”获取回溯。

如果我输入一个不存在的子域,我最终会进入/ var / www /

这是配置:

<VirtualHost *:80>
    ServerName files.mydomain.com
    DocumentRoot /var/www/rcane/files.mydomain.com/
</VirtualHost>

<VirtualHost *:80>
    ServerName media.mydomain.com
    DocumentRoot /var/www/rcane/media.mydomain.com/
</VirtualHost>

<VirtualHost *:80>
    ServerName wordpress.mydomain.com
    DocumentRoot /var/www/rcane/wordpress.mydomain.com/
</VirtualHost>

<VirtualHost *:80>
    ServerName myml.mydomain.com
    DocumentRoot /var/www/johan/ayml/
</VirtualHost>

<VirtualHost *:80>
    ServerName johan.mydomain.com
    DocumentRoot /var/www/johan/
</VirtualHost>

<VirtualHost *:80>
    ServerName phpmyadmin.mydomain.com
    DocumentRoot /usr/share/phpmyadmin/
</VirtualHost>

<VirtualHost *:80>
    ServerName sqlbuddy.mydomain.com
    DocumentRoot /var/www/sqlbuddy/
</VirtualHost>

<VirtualHost *:80>
    ServerName server.mydomain.com
    DocumentRoot /var/www/
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin me@mydomain.com
    ServerName mydomain.com
    ServerAlias *.mydomain.com
    DocumentRoot /var/www/rcane/mydomain.com/
</VirtualHost>

以下是LogLevel debug的错误日志:

[Sat Apr 28 13:42:24 2012] [debug] core.c(3112): [client 01.254.002.30] r->uri = /rcane/server.mydomain.com/
[Sat Apr 28 13:42:24 2012] [debug] core.c(3118): [client 01.254.002.30] redirected from r->uri = /rcane/server.mydomain.com/
[Sat Apr 28 13:42:24 2012] [debug] core.c(3118): [client 01.254.002.30] redirected from r->uri = /rcane/server.mydomain.com/
[Sat Apr 28 13:42:24 2012] [debug] core.c(3118): [client 01.254.002.30] redirected from r->uri = /rcane/server.mydomain.com/
[Sat Apr 28 13:42:24 2012] [debug] core.c(3118): [client 01.254.002.30] redirected from r->uri = /rcane/server.mydomain.com/
[Sat Apr 28 13:42:24 2012] [debug] core.c(3118): [client 01.254.002.30] redirected from r->uri = /rcane/server.mydomain.com/
[Sat Apr 28 13:42:24 2012] [debug] core.c(3118): [client 01.254.002.30] redirected from r->uri = /rcane/server.mydomain.com/
[Sat Apr 28 13:42:24 2012] [debug] core.c(3118): [client 01.254.002.30] redirected from r->uri = /rcane/server.mydomain.com/
[Sat Apr 28 13:42:24 2012] [debug] core.c(3118): [client 01.254.002.30] redirected from r->uri = /rcane/server.mydomain.com/
[Sat Apr 28 13:42:24 2012] [debug] core.c(3118): [client 01.254.002.30] redirected from r->uri = /rcane/server.mydomain.com/
[Sat Apr 28 13:42:24 2012] [debug] core.c(3118): [client 01.254.002.30] redirected from r->uri = /
[Sat Apr 28 13:42:24 2012] [debug] mod_deflate.c(615): [client 01.254.002.30] Zlib: Compressed 627 to 379 : URL /rcane/server.mydomain.com/

2 个答案:

答案 0 :(得分:2)

您上次ServerName指令可能存在问题。语法应为

  

ServerName fully-qualified-domain-name[:port]

尝试

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

    DocumentRoot /var/www/mydomain.com/
</VirtualHost>

答案 1 :(得分:0)

所以解决方法是删除这个htaccess文件:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^.*$ rcane/server.mydomain.com/ [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ rcane/server.mydomain.com/