Apache服务器别名在ubuntu中似乎不起作用

Apache服务器别名在ubuntu中似乎不起作用,apache,ubuntu,server,apache2.4,Apache,Ubuntu,Server,Apache2.4,我正在尝试在apache2.4.25中创建多个serveralias。它可以工作,但其中一个serveralias有时会显示403 fobidden错误。这是我的apache虚拟配置 <VirtualHost *:80> ServerName sajhamanch.com ServerAlias www.sajhamanch.com ServerAlias english.sajhamanch.com ServerAlias webmail.sajhamanch.com Se

我正在尝试在apache2.4.25中创建多个serveralias。它可以工作,但其中一个serveralias有时会显示403 fobidden错误。这是我的apache虚拟配置

    <VirtualHost *:80>
ServerName sajhamanch.com
ServerAlias www.sajhamanch.com
ServerAlias english.sajhamanch.com
ServerAlias webmail.sajhamanch.com
ServerAlias autoconfig.sajhamanch.com
ServerAlias autodiscover.sajhamanch.com
DocumentRoot /home/sajhamanch/public_html
ErrorLog /var/log/virtualmin/sajhamanch.com_error_log
CustomLog /var/log/virtualmin/sajhamanch.com_access_log combined
ScriptAlias /cgi-bin/ /home/sajhamanch/cgi-bin/
ScriptAlias /AutoDiscover/AutoDiscover.xml /home/sajhamanch/cgi-bin/autoconfig.cgi
ScriptAlias /Autodiscover/Autodiscover.xml /home/sajhamanch/cgi-bin/autoconfig.cgi
ScriptAlias /autodiscover/autodiscover.xml /home/sajhamanch/cgi-bin/autoconfig.cgi
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/sajhamanch/public_html>
Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
AddType application/x-httpd-php .php
AddType application/x-httpd-php7.0 .php7.0
</Directory>
<Directory /home/sajhamanch/cgi-bin>
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.sajhamanch.com
RewriteRule ^(.*) https://host.crystalsoft.com.np:20000 [R]
<LocationMatch "^(.*\.php)$">
        ProxyPass fcgi://127.0.0.1:9002/home/sajhamanch/public_html
    </LocationMatch>
Redirect /mail/config-v1.1.xml /cgi-bin/autoconfig.cgi
Redirect /.well-known/autoconfig/mail/config-v1.1.xml /cgi-bin/autoconfig.cgi
</VirtualHost>
<VirtualHost 139.59.22.58:443>
ServerName sajhamanch.com
ServerAlias www.sajhamanch.com
ServerAlias english.sajhamanch.com
ServerAlias webmail.sajhamanch.com
ServerAlias autoconfig.sajhamanch.com
ServerAlias autodiscover.sajhamanch.com
DocumentRoot /home/sajhamanch/public_html
ErrorLog /var/log/virtualmin/sajhamanch.com_error_log
CustomLog /var/log/virtualmin/sajhamanch.com_access_log combined
ScriptAlias /cgi-bin/ /home/sajhamanch/cgi-bin/
ScriptAlias /AutoDiscover/AutoDiscover.xml /home/sajhamanch/cgi-bin/autoconfig.cgi
ScriptAlias /Autodiscover/Autodiscover.xml /home/sajhamanch/cgi-bin/autoconfig.cgi
ScriptAlias /autodiscover/autodiscover.xml /home/sajhamanch/cgi-bin/autoconfig.cgi
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/sajhamanch/public_html>
Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
AddType application/x-httpd-php .php
AddType application/x-httpd-php7.0 .php7.0
</Directory>
<Directory /home/sajhamanch/cgi-bin>
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.sajhamanch.com
RewriteRule ^(.*) https://host.crystalsoft.com.np:20000 [R]
SSLEngine on
SSLCertificateFile /home/sajhamanch/ssl.cert
SSLCertificateKeyFile /home/sajhamanch/ssl.key
SSLProtocol +TLSv1 +TLSv1.1 +TLSv1.2
####### http2 #########
Protocols h2 http/1.1
######## php fpm link #############
 <LocationMatch "^(.*\.php)$">
        ProxyPass fcgi://127.0.0.1:9002/home/sajhamanch/public_html
    </LocationMatch>
SSLCACertificateFile /home/sajhamanch/ssl.ca
Redirect /mail/config-v1.1.xml /cgi-bin/autoconfig.cgi
Redirect /.well-known/autoconfig/mail/config-v1.1.xml /cgi-bin/autoconfig.cgi
</VirtualHost>

服务器名sajhamanch.com
ServerAlias www.sajhamanch.com
ServerAlias english.sajhamanch.com
ServerAlias webmail.sajhamanch.com
ServerAlias autoconfig.sajhamanch.com
ServerAlias autodiscover.sajhamanch.com
DocumentRoot/home/sajhamanch/public\u html
ErrorLog/var/log/virtualmin/sajhamanch.com\u error\u log
CustomLog/var/log/virtualmin/sajhamanch.com\u访问\u日志组合
ScriptAlias/cgi-bin//home/sajhamach/cgi-bin/
ScriptAlias/AutoDiscover/AutoDiscover.xml/home/sajhamach/cgi-bin/autoconfig.cgi
ScriptAlias/Autodiscover/Autodiscover.xml/home/sajhamach/cgi-bin/autoconfig.cgi
ScriptAlias/autodiscover/autodiscover.xml/home/sajhamach/cgi-bin/autoconfig.cgi
DirectoryIndex.html index.htm index.php index.php4 index.php5
选项-索引+包括noexec+符号链接所有者匹配
通融
AllowOverride All Options=ExecCGI,Includes noexec,index,multiview,symlinksFownerMatch
要求所有授权
AddType应用程序/x-httpd-php.php
AddType应用程序/x-httpd-php7.0.php7.0
通融
AllowOverride All Options=ExecCGI,Includes noexec,index,multiview,symlinksFownerMatch
要求所有授权
重新启动发动机
RewriteCond%{HTTP_HOST}=webmail.sajhamanch.com
重写规则^(.*)https://host.crystalsoft.com.np:20000 [R]
ProxyPassfcgi://127.0.0.1:9002/home/sajhamanch/public_html
重定向/mail/config-v1.1.xml/cgi-bin/autoconfig.cgi
重定向/.well-known/autoconfig/mail/config-v1.1.xml/cgi-bin/autoconfig.cgi
服务器名sajhamanch.com
ServerAlias www.sajhamanch.com
ServerAlias english.sajhamanch.com
ServerAlias webmail.sajhamanch.com
ServerAlias autoconfig.sajhamanch.com
ServerAlias autodiscover.sajhamanch.com
DocumentRoot/home/sajhamanch/public\u html
ErrorLog/var/log/virtualmin/sajhamanch.com\u error\u log
CustomLog/var/log/virtualmin/sajhamanch.com\u访问\u日志组合
ScriptAlias/cgi-bin//home/sajhamach/cgi-bin/
ScriptAlias/AutoDiscover/AutoDiscover.xml/home/sajhamach/cgi-bin/autoconfig.cgi
ScriptAlias/Autodiscover/Autodiscover.xml/home/sajhamach/cgi-bin/autoconfig.cgi
ScriptAlias/autodiscover/autodiscover.xml/home/sajhamach/cgi-bin/autoconfig.cgi
DirectoryIndex.html index.htm index.php index.php4 index.php5
选项-索引+包括noexec+符号链接所有者匹配
通融
AllowOverride All Options=ExecCGI,Includes noexec,index,multiview,symlinksFownerMatch
要求所有授权
AddType应用程序/x-httpd-php.php
AddType应用程序/x-httpd-php7.0.php7.0
通融
AllowOverride All Options=ExecCGI,Includes noexec,index,multiview,symlinksFownerMatch
要求所有授权
重新启动发动机
RewriteCond%{HTTP_HOST}=webmail.sajhamanch.com
重写规则^(.*)https://host.crystalsoft.com.np:20000 [R]
斯伦金安
SSLCertificateFile/home/sajhamach/ssl.cert
SSLCertificateKeyFile/home/sajhamach/ssl.key
SSLProtocol+TLSv1+TLSv1.1+TLSv1.2
#######http2#########
协议h2 http/1.1
########php fpm链接#############
ProxyPassfcgi://127.0.0.1:9002/home/sajhamanch/public_html
SSLCACertificateFile/home/sajhamanch/ssl.ca
重定向/mail/config-v1.1.xml/cgi-bin/autoconfig.cgi
重定向/.well-known/autoconfig/mail/config-v1.1.xml/cgi-bin/autoconfig.cgi
这是我的脸

ExpiresActive On
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/bmp "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType text/html "access plus 0 seconds"
AddOutputFilterByType DEFLATE text/html text/plain text/css text/javascript application/javascript application/x-javascript
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "public,max-age=25920000"
</FilesMatch>
<IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /               
        RewriteCond %{HTTPS} off
        RewriteCond %{HTTP_HOST} ^www\.sajhamanch\.com
        RewriteRule ^(.*)$ https://www.sajhamanch.com/$1 [R=301,L]

        RewriteCond %{HTTPS} off
        RewriteCond %{HTTP_HOST} ^english\.sajhamanch\.com
        RewriteRule ^(.*)$ https://english.sajhamanch.com/$1 [R=301,L]

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

        RewriteRule ^index\.php$ - [L]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . /index.php [L]
</IfModule>
ExpiresActive开启
ExpiresByType应用程序/javascript“访问加1个月”
ExpiresByType应用程序/x-javascript“访问加1个月”
ExpiresByType文本/javascript“访问加1个月”
ExpiresByType文本/css“访问加1个月”
ExpiresByType image/gif“访问加1个月”
ExpiresByType图像/jpg“访问加1个月”
过期按类型图像/jpeg“访问加1个月”
ExpiresByType图像/png“访问加1个月”
ExpiresByType image/bmp“访问加1个月”
过期按类型应用程序/x-shockwave-flash“访问加1个月”
ExpiresByType text/html“访问加0秒”
AddOutputFilterByType DEFLATE text/html text/plain text/css text/javascript应用程序/javascript应用程序/x-javascript
标题集缓存控制“公共,最大年龄=25920000”
重新启动发动机
重写基/
重写条件%{HTTPS}关闭
重写cond%{HTTP_HOST}^www\.sajhamanch\.com
重写规则^(.*)$https://www.sajhamanch.com/$1[R=301,L]
重写条件%{HTTPS}关闭
重写cond%{HTTP_HOST}^english\.sajhamanch\.com
重写规则^(.*)$https://english.sajhamanch.com/$1[R=301,L]
重写cond%{HTTP_HOST}^sajhamanch\.com
重写规则^(.*)$https://www.sajhamanch.com/$1[R=301,L]
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
但当我访问时,apache有时会显示403错误页面

DNS配置中没有问题。我在所有页面中都有这些元标记

 <meta http-equiv="Cache-Control" content="no-cache" />
 <meta http-equiv="Pragma" content="no-cache" />
 <meta http-equiv="Expires" content="0" />


有什么问题吗?

对于初学者,我看到您将“从所有人中允许”(2.2)与
要求所有授权的人(2.4.x)混合使用,删除前者,不要混合使用2.2和2.4指令。谢谢@ezra-s。成功了:)