.htaccess在Linux环境中抛出内部服务器错误

时间:2014-10-11 13:22:30

标签: apache .htaccess

多年前,围绕着 friendly-urls 的热潮,由我认为来自Yahoo!的Firefox扩展指导开发人员在分析页面后提供一些优化提示,给出成绩分数(对不起,我不记得名字)我已经构建了这个 .htaccess 文件:

# Far-away Cache Expiration
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Expires "Thu, 15 Apr 2050 20:00:00 GMT"
</FilesMatch>

# Output Compression

<IfModule mod_deflate.c>

    <FilesMatch "\.(css|js|html|php)$">
        SetOutputFilter DEFLATE
    </FilesMatch>

</IfModule>

<IfModule mod_setenvif.c>
    # Netscape 4.x has some problems...
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    # Netscape 4.06-4.08 have some more problems
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    # MSIE masquerades as Netscape, but it is fine
    BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
    # Don't compress images or already compressed files
    SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI .(?:avi|mov|mp3|mp4|rm|flv|swf|mp?g)$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI .pdf$ no-gzip dont-vary
</IfModule>

# Headers Fix

<IfModule mod_headers.c>
    # Make sure proxies don't deliver the wrong content
    Header append Vary User-Agent env=!dont-vary
</IfModule>

# ETag, whatever is that

Header unset ETag

FileETag None

# Rewrite Rules

RewriteEngine On

RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php [L]

从那以后,我一直在每个PHP项目中使用它,并且我一直在为A级打分。但我过去总是在Windows环境中开发。

昨天,我第一次成功安装了Linux Mint并在虚拟机中设置了开发环境。

尽管新手在不同的操作系统中遇到了所有问题,但当我测试其中一个在Windows中工作正常的项目时,我收到了内部服务器错误。

并且,您可能认为这很荒谬,但我从未学会如何从Apache的日志中挖掘信息,因此我无法自己解决这个问题。

我知道的一件事是,如果删除RewriteEngine On行以上的所有内容,Apache就不会引发任何错误,整个应用程序都能正常运行。

它可能是什么,最重要的是,为什么会发生这种情况?

根据评论中的要求, apachectl -l <​​/ strong>的输出:

Compiled in modules:
  core.c
  mod_so.c
  mod_watchdog.c
  http_core.c
  mod_log_config.c
  mod_logio.c
  mod_version.c
  mod_unixd.c

apachectl -M 的输出:

Loaded Modules:
 core_module (static)
 so_module (static)
 watchdog_module (static)
 http_module (static)
 log_config_module (static)
 logio_module (static)
 version_module (static)
 unixd_module (static)
 access_compat_module (shared)
 alias_module (shared)
 auth_basic_module (shared)
 authn_core_module (shared)
 authn_file_module (shared)
 authz_core_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 filter_module (shared)
 mime_module (shared)
 mpm_prefork_module (shared)
 negotiation_module (shared)
 php5_module (shared)
 rewrite_module (shared)
 setenvif_module (shared)
 status_module (shared)

0 个答案:

没有答案