设置WordPress MU,通配符dns和apache虚拟主机

我pipe理运行WordPress MU的服务器。 托pipe在服务器上的不同博客可以作为子域访问,例如blog1.mydomain.tld,blog2.mydomain.tld等。

我还需要使用相同的服务器运行自定义应用程序(reports.mydomain.tld)。

我的虚拟主机configuration如下:

NameVirtualHost mydomain.tld:80 <VirtualHost mydomain.tld:80> ServerName mydomain.tld ServerAlias *.mydomain.tld ServerAdmin [email protected] DocumentRoot /usr/local/www/mydomain.tld </VirtualHost> <VirtualHost reports.mydomain.tld> ServerName reports.mydomain.tld ServerAlias reports.mydomain.tld ServerAdmin [email protected] DocumentRoot /usr/local/www/reports.mydomain.tld/app/webroot/ </VirtualHost> 

当我尝试访问子域reports.mydomain.tld时,WordPress [剩余文本丢失]

我build议不要在VirtualHostNameVirtualHost指令中使用主机名。 而是使用IP地址或通配符。

此外,当NameVirtualHost'ing和一个请求的主机名可以匹配任一虚拟主机,那么第一个虚拟主机优先。 在你的情况下,这意味着通配符捕获所有。

您也可以删除多余的ServerAlias

改为:

 NameVirtualHost *:80 <VirtualHost *:80> ServerName reports.mydomain.tld ServerAdmin [email protected] DocumentRoot /usr/local/www/reports.mydomain.tld/app/webroot </VirtualHost> <VirtualHost *:80> ServerName mydomain.tld ServerAlias *.mydomain.tld ServerAdmin [email protected] DocumentRoot /usr/local/www/mydomain.tld </VirtualHost> 

我会build议如下:

 <VirtualHost mydomain.com:80> ServerName mydomain.com ServerAdmin [email protected] AddType application/x-httpd-php .php DocumentRoot /path/to/my/app/ <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$"> ExpiresActive On ExpiresDefault "access plus 1 year" </FilesMatch> RewriteEngine On RewriteRule (.*)-cb\d+\.(.*)$ $1.$2 [L] <Directory "/path/to/my/app/"> Options Indexes FollowSymLinks ExecCGI AllowOverride None Order allow,deny Allow from all </Directory> </VirtualHost> 

 <VirtualHost reports.mydomain.tld> ServerName reports.mydomain.tld ServerAlias reports.mydomain.tld ServerAdmin [email protected] DocumentRoot /usr/local/www/reports.mydomain.tld/app/webroot/ </VirtualHost> 

以上

 <VirtualHost mydomain.tld:80> ServerName mydomain.tld ServerAlias *.mydomain.tld ServerAdmin [email protected] DocumentRoot /usr/local/www/mydomain.tld </VirtualHost> 

应该做的伎俩:)