【发布时间】:2013-09-09 21:00:51
【问题描述】:
以下是我的 htaccess 代码,请告知我做错了什么。谢谢你。 我正在尝试添加错误文档。 404在网站根目录下。
ErrorDocument 404 /404.html
<FilesMatch "\.(jpg|jpeg|png|gif|swf|ico|css|js)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
AddDefaultCharset UTF-8
AddLanguage en-US .html .htm .css .js
#Header unset ETag
FileETag none
<IfModule mod_headers.c>
<FilesMatch "\.(js|css|xml|gz)$">
Header append Vary: Accept-Encoding
</FilesMatch>
</IfModule>
<IfModule mod_mime.c>
AddType application/javascript js
AddType application/vnd.ms-fontobject eot
AddType application/x-font-ttf ttf ttc
AddType font/opentype otf
AddType application/x-font-woff woff
AddType image/svg+xml svg svgz
AddEncoding gzip svgz
</Ifmodule>
#Gzip
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x- javascript application/javascript
AddOutputFilterByType DEFLATE image/x-icon image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype
</ifmodule>
#End Gzip
【问题讨论】:
-
404.html里面是什么,你怎么知道它不起作用? -
@anubhava 它只是有点风格。当我输入虚假地址时,它会将我带到标准 404。“未找到请求的 URL /sh/showhaus_v2/about/asfdsf 在此服务器上找不到。此外,在尝试使用时遇到 404 Not Found 错误ErrorDocument 来处理请求。”
-
好的,谢谢您的回复。
.htaccess是否启用? -
@anubhava 是的。其他一切都有效,只是不是 404
-
好的,你可以试试:
ErrorDocument 404 /
标签: html .htaccess http-status-code-404