子域总是重定向到WWW(主页)



我想要,当打开子域时返回现有的Wordpress页面,例如www.example.com/customizedwordpress-page.

服务器操作系统是CentOS 6.6,而Web服务器(httpd)是Apache 2.2.15。

它已经安装并配置了Wordpress,并为其mod_rewrite配置了.htaccess文件。

根文件夹是/var/www/html。

.htaccess文件位于/var/www/html/.htaccess:中

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

这个配置在一个域(例如example.com)上运行得很好。今天我想添加子域(例如subdomain.example.com)。

我尝试了多种解决方案,包括httpd.conf文件中带有/不带有NameVirtualHost的VirtualHosts,还添加了RewriteCond&重写规则在.htaccess文件中的mod_rewrite下。

NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin email-address-redacted
ServerName www.example.com
ServerAlias example.com
DocumentRoot /var/www/html
</VirtualHost>
<VirtualHost *:80>
ServerAdmin email-address-redacted
ServerName subdomain.example.com
ServerAlias subdomain.example.com
Redirect permanent / http://example.com/custom-wordpress-page
</VirtualHost>

同样在第一个VirtualHost中,我尝试了*.example.com,而不是关闭www.example.com。在第二个例子中,我尝试使用ProxyPass和ProxyPassReverse制作反向代理。

我没有使用:*80,而是尝试使用服务器的IP地址和域名。

在使用/不使用VirtualHosts的情况下使用.htaccess重写规则不会产生任何结果。

subdomain.example.com总是打开www.example.com,而不是www.example.com/customizedwordpress-page。

请记住,有很多这样的线程,但我尝试了很多,包括许多教程,但它们不能与Wordpress一起使用。

编辑:希望添加DNS记录中没有通配符。有NS记录,一个A记录用于example.com,一个记录用于子域example.com,以及指向example.com的www的CNAME记录。没有*。

托管提供商DNS记录有问题,配置正确,但我不得不打电话给提供商,检查他们系统中的记录并修复损坏的内容。在他们完成工作后,它工作正常。

最新更新