Bonfire with codeigniter内部服务器错误

时间:2017-03-11 08:58:20

标签: php .htaccess codeigniter-2 bonfire

我有一个篝火设置,运行正常。在服务器恢复到之前的备份后,它突然在http://office.barrecertification.com/中出现内部服务器错误。我的.htaccess文件是

# Helpful sections not specific to CodeIgniter - excerpted from
# https://github.com/h5bp/server-configs/

# ----------------------------------------------------------------------
# Proper MIME type for all files
# ----------------------------------------------------------------------

<IfModule mod_mime.c>

  # JavaScript
  # Normalize to standard type (it's sniffed in IE anyways)
  # tools.ietf.org/html/rfc4329#section-7.2
  AddType application/javascript js jsonp
  AddType application/json json

  # Audio
  AddType audio/mp4 m4a f4a f4b
  AddType audio/ogg oga ogg

  # Video
  AddType video/mp4 mp4 m4v f4v f4p
  AddType video/ogg ogv
  AddType video/webm webm
  AddType video/x-flv flv

  # SVG
  # Required for svg webfonts on iPad
  # twitter.com/FontSquirrel/status/14855840545
  AddType image/svg+xml svg svgz
  AddEncoding gzip svgz

  # Webfonts
  AddType application/font-woff woff
  AddType application/vnd.ms-fontobject eot
  AddType application/x-font-ttf ttf ttc
  AddType font/opentype otf

  # Assorted types
  AddType application/octet-stream safariextz
  AddType application/x-chrome-extension crx
  AddType application/x-opera-extension oex
  AddType application/x-shockwave-flash swf
  AddType application/x-web-app-manifest+json webapp
  AddType application/x-xpinstall xpi
  AddType application/xml rss atom xml rdf
  AddType image/webp webp
  AddType image/x-icon ico
  AddType text/cache-manifest appcache manifest
  AddType text/vtt vtt
  AddType text/x-component htc
  AddType text/x-vcard vcf

</IfModule>


# ----------------------------------------------------------------------
# Gzip compression
# ----------------------------------------------------------------------

<IfModule mod_deflate.c>

  # Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
  <IfModule mod_setenvif.c>
    <IfModule mod_headers.c>
      SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ 

HAVE_Accept-Encoding
      RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
    </IfModule>
  </IfModule>

  # Compress all output labeled with one of the following MIME-types
  # (for Apache versions below 2.3.7, you don't need to enable `mod_filter`
  # and can remove the `<IfModule mod_filter.c>` and `</IfModule>` lines as
  # `AddOutputFilterByType` is still in the core directives)
  <IfModule mod_filter.c>
    AddOutputFilterByType DEFLATE application/atom+xml \
                                  application/javascript \
                                  application/json \
                                  application/rss+xml \
                                  application/vnd.ms-fontobject \
                                  application/x-font-ttf \
                                  application/xhtml+xml \
                                  application/xml \
                                  font/opentype \
                                  image/svg+xml \
                                  image/x-icon \
                                  text/css \
                                  text/html \
                                  text/plain \
                                  text/x-component \
                                  text/xml
  </IfModule>

</IfModule>


# ----------------------------------------------------------------------
# UTF-8 encoding
# ----------------------------------------------------------------------

# Use UTF-8 encoding for anything served text/plain or text/html
AddDefaultCharset utf-8

# Force UTF-8 for a number of file formats
<IfModule mod_mime.c>
    AddCharset utf-8 .atom .css .js .json .rss .vtt .xml
</IfModule>


# ----------------------------------------------------------------------
# A little more security
# ----------------------------------------------------------------------

# To avoid displaying the exact version number of Apache being used, add the
# following to httpd.conf (it will not work in .htaccess):
# ServerTokens Prod

# "-Indexes" will have Apache block users from browsing folders without a
# default document Usually you should leave this activated, because you
# shouldn't allow everybody to surf through every folder on your server (which
# includes rather private places like CMS system folders).
<IfModule mod_autoindex.c>
  Options -Indexes
</IfModule>

# Block access to "hidden" directories or files whose names begin with a
# period. This includes directories used by version control systems such as
# Subversion or Git.
<IfModule mod_rewrite.c>
  RewriteCond %{SCRIPT_FILENAME} -d [OR]
  RewriteCond %{SCRIPT_FILENAME} -f
  RewriteRule "(^|/)\." - [F]
</IfModule>

# Block access to backup and source files. These files may be left by some
# text/html editors and pose a great security danger, when anyone can access
# them.
<FilesMatch "(^#.*#|\.(bak|config|dist|fla|inc|ini|log|psd|sh|sql|sw[op])|~)$">
  Order allow,deny
  Deny from all
  Satisfy All
</FilesMatch>


# ----------------------------------------------------------------------
# Start rewrite engine
# ----------------------------------------------------------------------

# Turning on the rewrite engine is necessary for the following rules and features.
# FollowSymLinks must be enabled for this to work.

<IfModule mod_rewrite.c>
  Options +FollowSymlinks
  RewriteEngine On

  # If you installed Bonfire in a subfolder, you will need to
  # change the following line to match the subfolder you need.
  # http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase
  RewriteBase / 

  # Removes access to the system folder by users.
  # Additionally this will allow you to create a System.php controller,
  # previously this would not have been possible.
  # 'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} ^bonfire/codeigniter.*
  RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>

# Rewrite "www.example.com -> example.com"

<IfModule mod_rewrite.c>
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
</IfModule>



# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to index.php

<IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>


<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 index.php
</IfModule>
<IfModule pagespeed_module>
    ModPagespeed off
</IfModule>

它安装在http://barrecertification.com/office中,用作office.barrecetification.com的子域。

这是root diretory的.htaccess

 # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php?/$1 [QSA,L]


    #----- START DAP -----
    RewriteCond %{REQUEST_FILENAME} -f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} (.*)/wp-content/uploads/(.*) 
    RewriteCond %{REQUEST_FILENAME} !(.*)(\.php|\.css|\.js|\.jpg|\.gif|\.png|\.txt|\.ico|\.jpeg)$ 
    RewriteRule (.*) /dap/client/website/dapclient.php?dapref=%{REQUEST_URI}&plug=wp&%{QUERY_STRING}  [L] 
    #----- END DAP -----


    # TN Expires Caching Start #

    ExpiresActive On
    ExpiresByType text/css "access 1 month"
    ExpiresByType text/html "access 1 month"
    ExpiresByType image/gif "access 1 year"
    ExpiresByType image/png "access 1 year"
    ExpiresByType image/jpg "access 1 year"
    ExpiresByType image/jpeg "access 1 year"
    ExpiresByType image/x-icon "access 1 year"
    ExpiresByType application/pdf "access 1 month"
    ExpiresByType application/javascript "access 1 month"
    ExpiresByType text/x-javascript "access 1 month"
    ExpiresByType application/x-shockwave-flash "access 1 month"
    ExpiresDefault "access 1 month"

    # TN Expires Caching End #
    </IfModule>

# END WordPress

# php -- BEGIN cPanel-generated handler, do not edit
# NOTE this account's php is controlled via FPM and the vhost, this is a place holder.
# Do not edit. This next line is to support the cPanel php wrapper (php_cli).
# AddType application/x-httpd-ea-php70 .php .phtml
# php -- END cPanel-generated handler, do not edit

<IfModule pagespeed_module>
    ModPagespeed off
</IfModule>

我无法弄清楚为什么会发生这种情况。 你能帮忙吗

1 个答案:

答案 0 :(得分:1)

如果您无权访问error.log文件,则始终可以设置本地wampxampp服务器。这或多或少都是我做的,测试并看看发生了什么。

在您的情况下,错误消息是

  

[core:alert] [pid 10504] [client :: 1:57830] /var/www/htaccess-test/office/.htaccess:缺少SetEnvIfNoCase的可变表达式

查看SetEnvIfNoCase

Syntax: SetEnvIfNoCase attribute regex [!]env-variable[=value] [[!]env-variable[=value]] ...

并将其与.htaccess文件中的指令进行比较

SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$

表明,有两个参数,其中至少需要三个参数。 attributeregex在那里,但没有定义环境变量。

当我第一次看到这个问题时,我错过了SetEnvIfNoCase

下面的一行
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ 

HAVE_Accept-Encoding

当我加入这两行时,它变为

SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding

并且错误消失了(至少在我的环境中)。