Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Favicon可能因为.htaccess而卡住_.htaccess_Mod Rewrite_Favicon - Fatal编程技术网

Favicon可能因为.htaccess而卡住

Favicon可能因为.htaccess而卡住,.htaccess,mod-rewrite,favicon,.htaccess,Mod Rewrite,Favicon,我制作了一个自定义的.htaccess文件,以便在我的网站上使用“干净的URL”,但现在我的favicon已经停止工作。我想那是因为我的重写规则,但我不确定。 favicon作为/favicon.ico放置在根目录中,并在我的站点的标题中调用。 这是我使用的htaccess: #rewite part Options +FollowSymlinks RewriteEngine On RewriteCond %{http_host} ^theroyalinstitute.com [NC] Rew

我制作了一个自定义的.htaccess文件,以便在我的网站上使用“干净的URL”,但现在我的favicon已经停止工作。我想那是因为我的重写规则,但我不确定。 favicon作为/favicon.ico放置在根目录中,并在我的站点的标题中调用。 这是我使用的htaccess:

#rewite part
Options +FollowSymlinks
RewriteEngine On

RewriteCond %{http_host} ^theroyalinstitute.com [NC]
RewriteRule ^(.*)$ http://www.theroyalinstitute.com/$1 [L,R=301] 

AddType image/x-icon .ico 
AddType text/xml .xml
AddType application/x-woff .woff

#Etags
Header unset Pragma 
Header unset ETag
FileETag none

#Expires-header regelt de caching in de browser.
<IfModule mod_expires.c>
    ExpiresActive On

    ExpiresByType text/html A0

    ExpiresByType text/xml A60


    #One month
    ExpiresByType image/x-icon A604800

    ExpiresByType image/gif A604800
    ExpiresByType image/png A604800
    ExpiresByType image/jpeg A604800

    ExpiresByType application/x-shockwave-flash A604800

    ExpiresByType application/x-woff A2592000
    ExpiresByType application/x-javascript A2592000
    ExpiresByType text/css A2592000

</IfModule>

RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^([^\.]+)/?$ index.php [L]

# compress all js & css:
AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/x-javascript application/x-woff application/json
Header append Vary Accept-Encoding
#重新布线部件
选项+FollowSymlinks
重新启动发动机
RewriteCond%{http_host}^theroyalinstitute.com[NC]
重写规则^(.*)$http://www.theroyalinstitute.com/$1[L,R=301]
AddType image/x-icon.ico
AddType text/xml.xml
AddType应用程序/x-woff.woff
#埃塔格
标题未设置Pragma
标题未设置ETag
FileTag无
#在de浏览器中过期标头regelt de缓存。
过期于
ExpiresByType文本/html A0
ExpiresByType文本/xml A60
#一个月
ExpiresByType图像/x图标A604800
过期按类型图像/gif A604800
ExpiresByType图像/png A604800
过期按类型图像/jpeg A604800
过期按类型应用/x-shockwave-flash A604800
按类型应用程序到期/x-woff A2592000
ExpiresByType应用程序/x-javascript A2592000
ExpiresByType文本/css A2592000
重写cond%{REQUEST_URI}=/图标文件
重写规则^([^\.]+)/?$index.php[L]
#压缩所有js和css:
AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml应用程序/x-javascript应用程序/x-woff应用程序/json
头附加变量接受编码

谁有答案、提示或解决方案?

尝试更改此行:

RewriteCond %{REQUEST_URI} !=/favicon.ico
为此:

RewriteCond %{REQUEST_URI} !/favicon\.ico$

感谢您的评论,显然问题出在CHMOD权限上,而不是整个重写部分

您可能会考虑将www.example.com转发到example.com。我觉得常常多余的前缀很烦人你能在浏览器中直接浏览到favico吗?例如www.example.com/favico.ico对我来说,以下内容被视为禁止:@Andrew M:不,我不能直接浏览到它,我也得到了一个403禁止。。。我真的不知道如何解决…@Bart,好吧,我想可能是该文件的权限,而不是重写(但我不是apache专家)。事实上,重定向到但抛出了一个禁止,这表明重写工作正常,但文件本身由于某种原因无法提供服务。好的,在我最后的评论中,WRT这两个链接,非www被重定向到www,但在重定向后被禁止。(因此将我的URL转换为链接,但删除了前缀)