apache2配置中ServerName和ServerAlias有什么区别? [英] What is the difference between ServerName and ServerAlias in apache2 configuration?

查看:53
本文介绍了apache2配置中ServerName和ServerAlias有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在配置我的 apache2 服务器,我想知道 ServerName 和 ServerAlias 之间有什么区别.

I am configurating my apache2 server and I wonder whats the difference between ServerName and ServerAlias.

ServerName 是否总是像 google.de 一样没有 www 的名称ServerAlias 是 www.google.de

Is the ServerName always a name without www as like google.de and the ServerAlias is www.google.de

即使是这样,我也不明白:) 对不起.

Even if it's like this, I don't get it :) sorry.

我不是专业人士(现在)所以感谢您的帮助!每一个帮助都会立即被点赞.

I am not a professional (now) so thank you for your help! Every help will upvoted immediately.

推荐答案

来自 文档:

服务器名称:服务器用来标识自己的主机名和端口

ServerName: Hostname and port that the server uses to identify itself

ServerAlias:将请求与名称虚拟主机匹配时使用的主机的备用名称

ServerAlias: Alternate names for a host used when matching requests to name-virtual hosts

大多数人只是使用 ServerName 来设置网站的主要"地址(例如mywebsite.com")和 ServerAlias 来添加网站将要使用的其他地址绑定到(例如www.mywebsite.com").

Most people simply use ServerName to set the 'main' address of the website (eg. 'mywebsite.com') and ServerAlias to add additional addresses the website will be bound to (eg. 'www.mywebsite.com').

然而,两者之间存在细微差别:

Yet, there are subtle differences between the two:

  • ServerName 也可以接受端口号,而 ServerAlias 不能.
  • ServerAlias 可以接受通配符(例如 *.mywebsite.com),而 ServerName 不能.
  • ServerName can accept port numbers as well, while ServerAlias cannot.
  • ServerAlias can accept wildcards (eg. *.mywebsite.com), while ServerName cannot.

阅读文档以了解原因.

这篇关于apache2配置中ServerName和ServerAlias有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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