本文介绍了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.deand 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.

推荐答案

来自文档:

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有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 16:41