开发者

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

开发者 https://www.devze.com 2023-02-10 20:09 出处:网络
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.

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

精彩评论

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

关注公众号