开发者

How to make a web site to work without www prefix in its name?

Normally, I drop www when typing in the URL. Frankly, one important site I visit, don't support such shorted URL and I want to ask开发者_开发知识库 them to fix it.

Is a solution a configfile fix? Or does it require a special provider-related service?


If they have Rewrite Engine enabled, they can create .htaccess file with this rule

RewriteEngine on

RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteRule (.*) http://www.example.com/$1 [L,R=301]

This way everyone who comes to http://example.com is redirected to http://www.example.com automatically.


It's a virtual host configuration or a DNS C name, depending on how they have it configured.

Suggest they create a C NAME for the non-"www" version of their URL.


If they have access to the VirtualHost container then they can just add the ServerAlias directive:

ServerAlias example.com

This will require no redirection so it will be faster to the user.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜