apache - 子域重定向到 www

标签 apache redirect subdomain

我在 apache 服务器上运行域 example.comtest.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/

相关文章:

apache - 如何在一个文件中设置多个虚拟主机

javascript - 在apache上使用nodeJS发送文件

php - 通过两个独立的 joomla 站点进行 Joomla 身份验证

ssl - 主要 SSL 重新路由 HTTP 附加组件

php - 3 关于 .htaccess 的问题

php - 浏览器不兼容请使用 Mozilla Firefox 3.2 以上或 IE 8.0 以上

php - 使用 Zend 框架将旧 URL 重定向/转发(类似于 301 状态)到新 Controller /操作

ASP.NET Response.Redirect 使用 302 而不是 301

subdomain - 一个 CNAME 文件用于 2 个不同的域。 gh-pages X namecheap

.htaccess - 使用 .htaccess 以 root 身份动态加载子域文件夹