<;虚拟主机>;使我们的Apache服务器产生;“内部错误”;

<;虚拟主机>;使我们的Apache服务器产生;“内部错误”;,apache,.htaccess,internal-server-error,Apache,.htaccess,Internal Server Error,当我将指令添加到下面的.htaccess文件中时,我们的生产服务器news.XXX(我写的是XXX,而不是我们的真实域名)出现内部错误而失败 请帮助理解错误的原因 Header set X-UA-Compatible "IE=edge" AddType text/html .html AddType text/x-component .htc AddHandler server-parsed .html .xml Options -Indexes +Includes +ExecCGI Order

当我将
指令添加到下面的
.htaccess
文件中时,我们的生产服务器
news.XXX
(我写的是
XXX
,而不是我们的真实域名)出现内部错误而失败

请帮助理解错误的原因

Header set X-UA-Compatible "IE=edge"
AddType text/html .html
AddType text/x-component .htc
AddHandler server-parsed .html .xml
Options -Indexes +Includes +ExecCGI
Order allow,deny
Allow from all


#<FilesMatch "\.(xml|css|js)$">
#  ExpiresActive on
#  ExpiresDefault "access plus 15 minutes"
#</FilesMatch>

#<IfModule mod_expires.c>
#  ExpiresActive on
#  ExpiresDefault "access"
#  ExpiresDefault "access plus 15 minutes"
#  ExpiresByType text/html "access"
#  ExpiresByType text/plain "access"
#  ExpiresByType text/csv "access"
#  ExpiresByType application/xml "access"
#</IfModule>


RewriteEngine On

#DirectoryIndex /working-on-server.html
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteRule ^(.*)$ /working-on-server.html [L]

# Replaced real domain with XXX
<VirtualHost victor11.XXX>
DirectoryIndex /cgi-bin/news/index.NEW.fcgi
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /cgi-bin/news/index.NEW.fcgi [L,QSA]
</VirtualHost>

DirectoryIndex /cgi-bin/news/index.fcgi
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /cgi-bin/news/index.fcgi [L,QSA]
标题集X-UA-Compatible“IE=edge”
AddType text/html.html
AddType text/x-component.htc
AddHandler服务器已解析.html.xml
选项-索引+包含+执行CGI
命令允许,拒绝
通融
#
#过期于
#ExpiresDefault“访问加15分钟”
#
#
#过期于
#ExpiresDefault“访问权限”
#ExpiresDefault“访问加15分钟”
#ExpiresByType文本/html“访问”
#ExpiresByType文本/纯“访问”
#ExpiresByType文本/csv“访问权限”
#ExpiresByType应用程序/xml“访问”
#
重新启动发动机
#目录索引/working-on-server.html
#重写cond%{REQUEST_FILENAME}-D
#重写cond%{REQUEST_FILENAME}-F
#重写规则^(.*)$/working-on-server.html[L]
#将实域替换为XXX
目录索引/cgi-bin/news/index.NEW.fcgi
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^(.*)$/cgi-bin/news/index.NEW.fcgi[L,QSA]
目录索引/cgi-bin/news/index.fcgi
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^(.*)$/cgi-bin/news/index.fcgi[L,QSA]

VirtualHost指令仅在全局服务器作用域/真实配置文件中有效。它在htaccess或任何其他配置部分中无效

如果需要虚拟主机,则需要编辑Apache在启动时读取的配置文件


每个指令都在手册中列出了其有效的上下文。

VirtualHost指令不能在.htaccess文件中使用,因为Apache在包含.htaccess规则之前已经确定了正在使用的VirtualHost

如果有多个VirtualHost使用同一公共html文件夹,则可能需要执行以下操作:

<If "req('Host') == 'new.example.com'">
    DirectoryIndex /cgi-bin/news/index.NEW.fcgi
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /cgi-bin/news/index.NEW.fcgi [L,QSA]
</If>
<Else>
    DirectoryIndex /cgi-bin/news/index.fcgi
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /cgi-bin/news/index.fcgi [L,QSA]
</Else>

目录索引/cgi-bin/news/index.NEW.fcgi
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^(.*)$/cgi-bin/news/index.NEW.fcgi[L,QSA]
目录索引/cgi-bin/news/index.fcgi
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^(.*)$/cgi-bin/news/index.fcgi[L,QSA]