如何使用 htaccess 更改图像路径? [英] How to change image path using htaccess?

查看:22
本文介绍了如何使用 htaccess 更改图像路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在修复这个 joomla 网站.它使用 joomla 1.7 语言过滤器,因此它向 url 添加了后期修复.因此,当我查看带有图像的文章时,图像不显示.我试过 htaccess 重写规则.但它对我不起作用......这是我复制图片网址时得到的.

I'm fixing this joomla site. It uses joomla 1.7 language filter so it adds post fixes to the url. So when i view an artcle with images, image is not displaying. I tried htaccess rewrite rules. But it didn't work for me... this is what i get when i copy image url.

http://domain.com/en/images/myimage.png

但是当我检查代码时它的 images/myimage.png .如果我将代码编辑为 /images/myimage.png 它可以工作.

But when I check the code its images/myimage.png . If i edit code to /images/myimage.png it works.

这也是我尝试用 htaccess 做的事情,添加一个/".由于它不起作用,我想我必须更改整个网址.我没有太多的重写知识.请你们帮帮我好吗?

Tthis is what i try to do with htaccess too, to add a "/". Since it didn't work i guess i have to change whole url. I don't have much knowledge in rewriting. Can you guys help me please?

推荐答案

在您的 .htaccess 中试一试:

Give this a go in your .htaccess:

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteRule ^.*/images/(.*)$ http://%{HTTP_HOST}/images/$1 [L,R=301]
</IfModule>

这会将您的 /en/images/... 请求重写为 /images/...

This will rewrite your /en/images/... requests to /images/...

请注意,这可能会对其他 URL 产生意想不到的后果.我建议在您自己的应用程序上正确测试它.

Note, this could have unexpected consequences for other URLs. I would suggest properly testing this on your own application.

这篇关于如何使用 htaccess 更改图像路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆