【问题标题】:Apache redirect empty subdomain to www-subdomainApache 将空子域重定向到 www-subdomain
【发布时间】:2011-03-14 09:48:06
【问题描述】:

我是 apache 配置的新手。

我希望将我的流量从http://example.com 重定向到http://www.example.com

我希望 www 始终出现在访问者浏览器的地址栏中。

我应该在 httpd.conf 中使用 mod_rewrite 还是其他任何东西?

【问题讨论】:

  • 抱歉,这个网站上已经有很多关于使用 apache 将 www 重定向到什么都没有或什么都没有重定向到 www 的问题。用一下搜索功能?

标签: apache redirect


【解决方案1】:

将以下内容添加到您的 httpd.conf

<VirtualHost *:80>
        ServerName adomainwihtoutwww.com
        Redirect permanent / http://www.yourdomain.com/
    </VirtualHost>

【讨论】:

  • Redirect permanent 如果以后要添加子域,不建议使用。在注册为虚拟主机之前使用该子域的用户可能永远无法访问该页面,因为其浏览器缓存中有301 Moved Permanently
猜你喜欢
  • 2016-05-17
  • 2014-03-25
  • 1970-01-01
  • 2012-04-01
  • 2013-09-18
  • 2015-05-19
  • 1970-01-01
  • 1970-01-01
  • 2018-06-01
相关资源
最近更新 更多