2012-11-25 64 views
0

我有我的.htaccess文件localhost/site/文件夹和localhost/site/images/car_model/ folder.I默认图像defaultcarimage-thumb.jpg要代替主图像的显示这个默认的图像时,原始图像也不会被发现。为此,我在谷歌搜索,发现this link如何显示的默认图像,如果原始图像是不存在的

和编辑我.htaccess如下:

RewriteEngine on 
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_URI} \.(gif|jpg|jpeg|png)$ 
RewriteRule .*/images/car_model/defaultcarimage-thumb.jpg [L] 

但没有什么变化。这段代码有什么问题?或者还有其他方法可以做到这一点吗?

回答

7

重写规则的语法是RewriteRule _url-send-by-user_ _rewrite-to_

因此改变你的重写规则,以这样的:

RewriteEngine on 
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_URI} \.(gif|jpg|jpeg|png)$ 
RewriteRule (.*) /images/car_model/defaultcarimage-thumb.jpg [L] 

并检查Pathes,无论是RewriteBase和重写规则,来论证路径。

+0

其实我认为你是对的,但我错过了这里提到的东西,图片是icon.y他们在CSS中定义像'#idname {background:url(../ images/icon.png)no-repeat ; }'。我可以用缺省图像替换丢失的图标吗? –

+1

如果您在-tag或css-block中使用图片,则无关紧要。如果您的默认图像不会显示,请尝试将.htaccess放入'/ images'文件夹,更改'RewriteRule(。*)defaultcarimage-thumb.jpg [L]'。 – take

+0

是的,我已经尝试过这种方式,但它仍然无法正常工作。我正在使用jquery mobile,我不知道它是否是jquery移动问题。我必须在列表视图中显示默认图标 –

相关问题