Centos 8 无效命令'

Centos 8 无效命令'

我目前在一台 VPS 上,我已将 9 个域名定向到该 VPS。在 httpd.conf 文件中,我插入了以下代码

       <VirtualHost*:80>
    DocumentRoot /var/www/non.com
    ServerName non.com
    ServerAlias www.non.com
    <Directory "/var/www/non.com">
      Options -Indexes +FollowSymLinks
        AllowOverride    </Directory>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/(.*) https://non.com:443/$1 [R,L]
</VirtualHost*:80>
<VirtualHost*:80>
    DocumentRoot /var/www/ne.com
    ServerName ne.com
    <Directory  "/var/www/ne.com">
         Options -Indexes +FollowSymLinks
        AllowOverride All
   </Directory>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/(.*) https://ne.com:443/$1 [R,L]
</VirtualHost*:80>`

我总是有同样的问题

AH00526:/etc/httpd/conf/httpd.conf 第 349 行语法错误:命令“<VirtualHost*:80”无效,可能是拼写错误或由服务器配置中未包含的模块定义

谢谢你的帮助

答案1

在打开的标签中,t 和 * 之间缺少一个空格,并且您在关闭标签时没有 host:port 部分。

<VirtualHost *:80>
  DocumentRoot /var/www/non.com
  ServerName non.com
  ServerAlias www.non.com
  <Directory "/var/www/non.com">
    Options -Indexes +FollowSymLinks
    AllowOverride    
  </Directory>
  RewriteEngine On
  RewriteCond %{HTTPS} !=on
  RewriteRule ^/(.*) https://non.com:443/$1 [R,L]
</VirtualHost>

<VirtualHost*:80>
  DocumentRoot /var/www/ne.com
  ServerName ne.com
  <Directory  "/var/www/ne.com">
    Options -Indexes +FollowSymLinks
    AllowOverride All
  </Directory>
  RewriteEngine On
  RewriteCond %{HTTPS} !=on
  RewriteRule ^/(.*) https://ne.com:443/$1 [R,L]
</VirtualHost>

相关内容