让Apache会自动去掉了www。? [英] Make apache automatically strip off the www.?

查看:133
本文介绍了让Apache会自动去掉了www。?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于种种原因,如饼干,搜索引擎优化,并让事情变得简单,我希望让Apache自动重定向的 http://www.foobar.com/anything http://foobar.com/anything 。我能想出的最好的是一个基于mod_rewrite的,畸形,有没有一些简单的简单的方法来告诉它重定向域ABC所有请求XYZ?

For various reasons, such as cookies, SEO, and to keep things simple, I would like to make apache automatically redirect any requests for http://www.foobar.com/anything to http://foobar.com/anything. The best I could come up with is a mod_rewrite-based monstrosity, is there some easy simple way to tell it "Redirect all requests for domain ABC to XYZ"?

PS:我发现这个有点相关的问题,但它是IIS和做的我想的正好相反。此外,它仍然是复杂的。

PS: I found this somewhat related question, but it's for IIS and does the opposite of what I want. Also it's still complex.

推荐答案

这是那么容易,因为:

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

适应主机名和IP地址需要:)

Adapt host names and IPs as needed :)

这篇关于让Apache会自动去掉了www。?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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