2011-12-20 30 views
0

我使用了一个生成器来使我的SEO友好的htaccess重写,在这里。Htaccess友好的SEO重写使图像停止加载?

RewriteRule ^([^/]*)/([^/]*) /detail.php?type=$1&?id=$2 [L] 

输出应www.site.com/type/id

现在,改写作品和页面重定向罚款,但该网站上的图像不再露面,他们各个击破... :(图片的URL是正确的,但似乎只是不想再加载任何帮助?应该有另一个重写规则来取消这个做其他的东西吗?如果是,什么?

回答

5

您现有的规则可能会影响图像。为了防止这种情况发生,请使用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] 
+0

谢谢。这工作 – Darius 2011-12-20 21:00:17

2

我不确定你的.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> 
+0

谢谢!这不适用于我的具体情况,但它似乎对我的其他项目很有用,我会使用它! – Darius 2011-12-20 21:00:37