Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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
.htaccess Htaccess友好SEO重写使图像停止加载?_.htaccess_Seo - Fatal编程技术网

.htaccess Htaccess友好SEO重写使图像停止加载?

.htaccess Htaccess友好SEO重写使图像停止加载?,.htaccess,seo,.htaccess,Seo,我使用了一个生成器来重写我的SEO友好的htaccess,在这里 RewriteRule ^([^/]*)/([^/]*) /detail.php?type=$1&?id=$2 [L] 输出应为www.site.com/type/id 现在,重写工作正常,页面重定向良好,但网站上的图像不再显示,它们都被破坏了…:(图像的URL是正确的,但似乎它只是不想再加载了,有什么帮助吗?是否应该有另一个重写规则来取消这一条,使其不再执行其他操作?如果有,什么?我不确定你的.htaccess看起来如

我使用了一个生成器来重写我的SEO友好的htaccess,在这里

RewriteRule ^([^/]*)/([^/]*) /detail.php?type=$1&?id=$2 [L]
输出应为www.site.com/type/id


现在,重写工作正常,页面重定向良好,但网站上的图像不再显示,它们都被破坏了…:(图像的URL是正确的,但似乎它只是不想再加载了,有什么帮助吗?是否应该有另一个重写规则来取消这一条,使其不再执行其他操作?如果有,什么?

我不确定你的.htaccess看起来如何,但我在我的项目中使用了一些方便的规则,它非常简单,并且涵盖了大多数问题:

<>
<IfModule mod_rewrite.c>
    ############################################
    # Enable mod_rewrite
    RewriteEngine On
    RewriteBase /

    ############################################
    ## always send 404 on missing files in these folders
    RewriteCond %{REQUEST_URI} !^/(media|assets)/

    ############################################
    # never rewrite for existing files, directories and links
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l

    RewriteRule .*$ index.php [L]
</IfModule>

############################################
#启用mod_重写
重新启动发动机
重写基/
############################################
##在这些文件夹中丢失文件时始终发送404
重写条件%{REQUEST_URI}!^/(媒体资产)/
############################################
#决不重写现有文件、目录和链接
重写cond%{REQUEST_FILENAME}!-f
重写cond%{REQUEST_FILENAME}!-d
重写cond%{REQUEST_FILENAME}!-l
重写规则。*$index.php[L]

您现有的规则可能会影响图像。若要防止这种情况,请使用RewriteCond指令,该指令将删除图像等的扩展。受规则影响,您可以根据需要添加其他扩展

#if its not an image, css, js etc
RewriteCond %{REQUEST_URI} !\.(gif|jpg|png|css|js|etc)$ [NC]
RewriteRule ^([^/]*)/([^/]*) /detail.php?type=$1&?id=$2 [L]

谢谢!这对我的具体案例不起作用,但它似乎对我的其他项目很有用,我会将其付诸使用!