删除“www。”从位置栏? [英] Removing "www." from location bar?

查看:120
本文介绍了删除“www。”从位置栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想要www。当任何人

通过我的域名访问我的网站时,永远不会在浏览器的位置栏中显示。即:


坏: http:// www。我的域名


好​​的: http :// my-domain-name


我如何有效(并且始终)删除www。当人们出于

习惯或因为他们认为需要时,输入www.my-domain-name,所以

只有my-domain -name"显示?


我是否使用某种类型的刷新或重定向元标题来执行此操作?


并且,我可以这样做*没有*适用于那些输入我的域名的用户

名称正确的方法是留下* off * thewww。


-

// rj@panix.com //

城市警察&国家警察和国民警卫队局警察和电视警察&电影警察

&制服&便衣警察&防暴警察在警察的警察之上警察的警察:这是一个充满警察的世界。 - Paleface


I want "www." to never show in a browser''s location bar when anyone
visits my site via my domain-name. i.e. :

BAD: http://www.my-domain-name

GOOD: http://my-domain-name

How can I efficiently (and always) remove the "www." when people, out of
habit or because they think they need to, type "www.my-domain-name", so
that only "my-domain-name" shows?

Do I do this with some type of refresh or redirect meta header?

And, can I do it so that *nothing* happens for those who type my domain
name in correctly by leaving *off* the "www."?

--
// rj@panix.com //
City cops & state cops & national guard & bureau cops & tv cops & movie cops
& uniform & plainclothes cops & riot cops & cops on top of cops on top of
cops on top of cops: it''s a world full of cops. -- Paleface

推荐答案

Russell Hoover写道:
Russell Hoover wrote:

>

我想要www。当任何人

通过我的域名访问我的网站时,永远不会在浏览器的位置栏中显示。即:


坏: http:// www。我的域名


好​​的: http :// my-domain-name


我如何有效(并且始终)删除www。当人们出于习惯或因为他们认为需要时,输入

" www.my-domain-name",这样只有my-domain -name"显示?


我是否使用某种类型的刷新或重定向元标题来执行此操作?


并且,我可以这样做以便不会发生任何事情对于那些键入我的域名

名称的人,请不要使用www。?
>
I want "www." to never show in a browser''s location bar when anyone
visits my site via my domain-name. i.e. :

BAD: http://www.my-domain-name

GOOD: http://my-domain-name

How can I efficiently (and always) remove the "www." when people, out
of habit or because they think they need to, type
"www.my-domain-name", so that only "my-domain-name" shows?

Do I do this with some type of refresh or redirect meta header?

And, can I do it so that nothing happens for those who type my domain
name in correctly by leaving off the "www."?



如果您的主机使用Apache与mod_rewrite,并允许您使用

..htaccess文件,您可以将以下内容放入。你的

web根目录中的htaccess文件:


RewriteEngine On

RewriteCond%{HTTP_HOST}!^ example.com

If your host uses Apache with mod_rewrite, and allows you to use
..htaccess files, you can put the following in an .htaccess file in your
web root directory:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^example.com


[NC]

RewriteRule ^(。*)http://example.com/
[NC]
RewriteRule ^(.*) http://example.com/


1 [L,R = 301]


这将重定向任何不是example.com的主机名。 (不包括www

在前面)该帐户到example.com(再次,没有www)。

R = 301意味着它将发送永久重定向(而不是

临时重定向)。


-

KimAndréAker?

- ki******@NOSPAMbetadome.com

(删除NOSPAM直接与我联系)
1 [L,R=301]

This will redirect any hostname that isn''t "example.com" (without www
in front) on that account to example.com (again, without the www).
The "R=301" means that it will send a permanent redirect (instead of a
temporary redirect).

--
Kim André Aker?
- ki******@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)


这篇关于删除“www。”从位置栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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