.htaccess错误。找不到错误

时间:2017-04-27 14:35:56

标签: apache .htaccess

由于某种原因,我没有被更改,我有一个.htaccess错误,不允许访问我的网站。 日志中的错误是

“[Thu Apr 27 09:20:19.310967 2017] [core:alert] [pid 17718] [client] /home//public_html/.htaccess:无效的命令'application / javascript',可能拼写错误或由a定义模块未包含在服务器配置“

如果我删除'application / javascript',它会直接转到下一行,并说这是一个错误。我的问题是,任何人都可以看到此文件中的错误在哪里?我一直看着它,但看不到它。谢谢你的时间

DirectoryIndex index.php

#for codeigniter
RewriteEngine on

RewriteCond $1 !^(index\.php|(.*)\.swf|forums|images|css|downloads|js|robots\.txt|favicon\.ico)

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ ./index.php?$1 [L,QSA]


RewriteCond %{SCRIPT_FILENAME} -d [OR]

RewriteCond %{SCRIPT_FILENAME} -f

RewriteRule "(^|/)\." - [F]

# for firewall
<FilesMatch ".*">

Require ip 192.88.134.0/23

Require ip 185.93.228.0/22

Require ip 2a02:fe80::/29

Require ip 66.248.200.0/22

</FilesMatch>

<IfModule mod_headers.c>

 Header set X-Frame-Options "DENY"

 <FilesMatch "\.(appcache|atom|crx|css|cur|eot|f4[abpv]|flv|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|tt[cf]|vcf|vtt|webapp|web[mp]|woff|xml|xpi)$">

     Header unset X-Frame-Options

 </FilesMatch>

 </IfModule>

 <IfModule mod_autoindex.c>

#Options -Indexes

</IfModule>


<IfModule mod_headers.c>

Header set X-Content-Type-Options "nosniff"

</IfModule>

<IfModule mod_headers.c>

 # (1)    (2)

 Header set X-XSS-Protection "1; mode=block"

 <FilesMatch "\.(appcache|atom|crx|css|cur|eot|f4[abpv]|flv|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|tt[cf]|vcf|vtt|webapp|web[mp]|woff|xml|xpi)$">

     Header unset X-XSS-Protection

 </FilesMatch>

 </IfModule>



Header set Strict-Transport-Security "max-age=31536000; includeSubDomains"

# ------------------------------------------------------------------------------

# | Compression                                                                      |

# ------------------------------------------------------------------------------

<IfModule mod_deflate.c>

# Force compression for mangled headers.

# http://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/ld+json \

                                  application/rss+xml \

                                  application/vnd.ms-fontobject \

                                  application/x-font-ttf \

                                  application/x-web-app-manifest+json \

                                  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>


<IfModule mod_headers.c>

Header set Cache-Control "no-transform"

</IfModule>

# ------------------------------------------------------------------------------

# | Expires headers                                                            |

 # ------------------------------------------------------------------------------



# The following expires headers are set pretty far in the future. If you

# don't control versioning with filename-based cache busting, consider

# lowering the cache time for resources such as style sheets and JavaScript

# files to something like one week.


<IfModule mod_expires.c>

ExpiresActive on

ExpiresDefault                                      "access plus 1 month"

# CSS

ExpiresByType text/css                              "access plus 1 year"

# Data interchange

ExpiresByType application/json                      "access plus 0 seconds"

ExpiresByType application/ld+json                   "access plus 0 seconds"

ExpiresByType application/xml                       "access plus 0 seconds"

ExpiresByType text/xml                              "access plus 0 seconds"

# Favicon (cannot be renamed!) and cursor images

ExpiresByType image/x-icon                          "access plus 1 week"

# HTML components (HTCs)

ExpiresByType text/x-component                      "access plus 1 month"

# HTML

ExpiresByType text/html                             "access plus 0 seconds"

# JavaScript

ExpiresByType application/javascript                "access plus 1 year"

# Manifest files

ExpiresByType application/x-web-app-manifest+json   "access plus 0 seconds"

ExpiresByType text/cache-manifest                   "access plus 0 seconds"

# Media

ExpiresByType audio/ogg                             "access plus 1 month"

ExpiresByType image/gif                             "access plus 1 month"

ExpiresByType image/jpeg                            "access plus 1 month"

ExpiresByType image/png                             "access plus 1 month"

ExpiresByType video/mp4                             "access plus 1 month"

ExpiresByType video/ogg                             "access plus 1 month"

ExpiresByType video/webm                            "access plus 1 month"

# Web feeds

ExpiresByType application/atom+xml                  "access plus 1 hour"

ExpiresByType application/rss+xml                   "access plus 1 hour"

# Web fonts

ExpiresByType application/font-woff                 "access plus 1 month"

ExpiresByType application/vnd.ms-fontobject         "access plus 1 month"

ExpiresByType application/x-font-ttf                "access plus 1 month"

ExpiresByType font/opentype                         "access plus 1 month"

ExpiresByType image/svg+xml                         "access plus 1 month"
</IfModule>


<Files 403.shtml>

order allow,deny

allow from all

</Files>

1 个答案:

答案 0 :(得分:1)

从命令AddOutputFilterByType DEFLATE开始,删除命令中这些内容类型参数之间的空行。

处理动态配置文件(.htaccess样式文件)的解析器发生故障:它假定命令以空行终止,并尝试将以下行解释为单独的命令。这会导致您收到错误消息。

如果你真的想保留这些空行(为了便于阅读),你需要用反斜杠(\)终止它们,表明该命令将继续在下一个(非空)行中。