阿帕奇非WWW到www重定向 [英] apache redirect from non www to www

查看:106
本文介绍了阿帕奇非WWW到www重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个房贷计算器,似乎从mookal.com重定向网站并不www.mookal.com结果
我的Apache配置如下:

I have a mortgage calculator site that doesn't seem to redirect from mookal.com to www.mookal.com
My apache config is as follows:

RewriteEngine On
### re-direct to www
RewriteCond %{http_host} !^www.mookal.com [nc]
RewriteRule ^(.*)$ http://www.mookal.com/$1 [r=301,nc] 

我是什么失踪?

推荐答案

使用重写引擎是解决这个问题的一个pretty重量级方式。这里有一个简单的解决方案:

Using the rewrite engine is a pretty heavyweight way to solve this problem. Here is a simpler solution:

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

然后你就会有另一个&LT;虚拟主机&GT; 服务器名称www.example.com 为您真正的服务器配置。 Apache的自动preserves后,任何东西使用重定向指令,这就是为什么这是一个普遍的误解时, / 方法是不行的(而事实上它)。

And then you'll have another <VirtualHost> section with ServerName www.example.com for your real server configuration. Apache automatically preserves anything after the / when using the Redirect directive, which is a common misconception about why this method won't work (when in fact it does).

这篇关于阿帕奇非WWW到www重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆