.htaccess RewriteEngine中断CGI应用程序

我的.htaccess文件在我的网站的根目录中,我缩小了问题的单行代码RewriteEngine on 。 我怎么知道这是这段代码? 因为我把除了RewriteEngine on之外的整个.htaccess文件作为一个testing删除了……而我的CGI应用程序仍然崩溃。

如果任何人有任何想法,为什么RewriteEngine on在线决定自行打破CGI应用程序,我很乐意听到!

PS – 万一你有兴趣,我想要工作的一段代码是帮助将所有域合并到一个域中(换行符只是为了便于阅读):

 RewriteEngine on RewriteCond %{HTTP_HOST} ^example.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301] RewriteCond %{THE_REQUEST} ^[AZ]{3,9}\ /index\.html RewriteRule (.*) http://www.example.com/ [R=301,L] 

很有可能mod_rewrite目前在你的Apacheconfiguration中没有启用(通常在httpd.conf中)。

如果启用,它会看起来像这样:

 # For Unix-like OSes LoadModule rewrite_module modules/mod_rewrite.so 

要么

 # For Windows LoadModule rewrite_module modules/mod_rewrite.dll 

以及

 # For both AddModule mod_rewrite.c 

在Apache 2.0 / 2.2中, AddModule行可能不是必需的。

有些操作系统将Apache模块加载器放在另一个目录中。 在Debian和Ubuntu Linux中,已安装模块的configuration文件位于/ etc / apache2 / modules-available中,可以使用a2enmod modulename激活; 在这种情况下a2enmod rewrite