我在 apache 服务器上运行域 example.com
和 test.example.com
。出于某种原因,当我尝试访问 test.example 时,它被重定向到 www.test.example,结果出现 Server not found
错误显示在浏览器中。 .htaccess(根目录和子域文件夹)文件都是空的。
其他事实
我有另一个子域 xyz.example.com
指向 public_html/xyz 目录,里面有一些内容(index.html 和“hello world message”),如果我使用 xyz.example 它工作正常.com 而不是 www.xyz.example.com。所以,你能帮我按顺序指出正确的方向吗?我有一个 vps,如果需要,我可以更改任何文件。
您可以在下面找到我的虚拟主机配置。
<VirtualHost xx.xxx.xxx:80>
ServerName test.example.com
ServerAlias www.test.example.com
DocumentRoot /home/example/public_html/test
ServerAdmin webmaster@test.example.com
UseCanonicalName Off
CustomLog /usr/local/apache/domlogs/test.example.com combined
CustomLog /usr/local/apache/domlogs/test.example.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
ScriptAlias /cgi-bin/ /home/example/public_html/test/cgi-bin/
# To customize this VirtualHost use an include file at the following location
# Include "/usr/local/apache/conf/userdata/std/2/example/test.example.com/*.conf"
</VirtualHost>
谢谢你的时间
最佳答案
在绑定(bind)配置区域中你不设置子域测试 在 example.com 区域中添加此行 >>
test.example.com IN A (xxx.xxx.xxx.xxx)
xxx.xxx.xxx.xxx是你服务器的ip
或者你没有启用你的虚拟主机配置>>
a2ensite test.example.com
test.example.com 是虚拟主机文件的名称。
关于apache - 子域重定向到 www,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12292740/