使用.htaccess重定向后,图片将不会显示 [英] Images won't show after redirect using .htaccess

查看:159
本文介绍了使用.htaccess重定向后,图片将不会显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新手。.我的htaccess现在有了

I am a newbie.. My htaccess now has

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
# /viewgallery.php?cname=Colorado-Fall&pcaption=Poked to /photos/Colorado-Fall/Poked.jpg
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+viewgallery\.php\?cname=([^&]+)&pcaption=([^&\s]+) [NC]
RewriteRule ^ /photos/%1/%2.jpg? [R=302,L,NE]
RewriteRule ^photos/([^/]+)/([^.]+)\.jpg$ /viewgallery.php?cname=$1&pcaption=$2 [QSA,L,NC,NE]

并且重定向有效,但图像不会显示在我的页(如果它们不在根文件夹中)。如果我有一个用图片创建的子目录(用于组织图片),则它们会产生找不到图片错误。

And redirect works but the images will not show up on my pages if they are not in the root folder. If I have a sub directory created with images(for organizing them), they will create an error as 'images not found'.

有解决方案吗?谢谢您的任何建议。...

Is there a solution for this? Thank you for any suggestions....

推荐答案

这可能是相对/绝对URL。尝试在页面标题中添加相对URI基:

This is probably a relative/absolute URL thing. Try adding a relative URI base to the header of your page:

<base href="/" />

或者其他正确的基数。要么,要么将所有链接更改为绝对URL:

Or whatever the correct base should be. Either that, or change all your links to absolute urls:

发件人:

<img src="subfolder/banner.jpg">

至:

<img src="/subfolder/banner.jpg">

这篇关于使用.htaccess重定向后,图片将不会显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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