让Apache会自动去掉了www。? [英] Make apache automatically strip off the 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屋!