我想使用apache2 VirtualHosts建立一个主站点和一个用于开发的子域。这就是我的site.conf虚拟主机文件的样子:
<VirtualHost *:80>
ServerName dev.mysite.com
DocumentRoot /var/www/site/subdomain
<Directory /var/www/site/subdomain >
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</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>
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel debug
CustomLog ${APACHE_LOG_DIR}/sub.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName www.mysite.com
ServerAlias mysite.com
DocumentRoot /var/www/site/main
<Directory /var/www/site/main >
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</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>
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
问题在于每次访问dev.mysite.com时,我都会收到mysite.com。
主站点没有htaccess,子域的.htaccess看起来像这样:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
我已经尝试了所有其他我能找到的解决方案(使用文字IP,重新排序,使用端口而不是命名主机)......我现在完全被困住了。该网站当然已启用。有人有任何想法吗?
答案 0 :(得分:0)
或者更确切地说,我不知道我必须将Wordpress网站网址配置为子域名,否则它只会重定向到给定的域名...
解决方案:打开wp_options
表并编辑site_url以包含子域。