Images won't show after redirect using .htaccess

浪尽此生 提交于 2019-12-25 05:38:09

问题


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....


回答1:


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

<base href="/" />

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

From:

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

to:

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


来源:https://stackoverflow.com/questions/18780562/images-wont-show-after-redirect-using-htaccess

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!