Forum Moderators: phranque

Message Too Old, No Replies

Mod Rewite removes images

         

ioanik

12:45 am on Jun 18, 2008 (gmt 0)

10+ Year Member



Ok,

I am now implementing mod_rewrite into a CMS.

The problem i have ran into is the link for images changes and I really cannot add a / to every image in the CMS....that would take just way to long.

How can i redirect all images to their appropriate locations as some images are loaded from the images folder and some images are located in /themes/theme folder I've looked through the forums and couldnt find a solution to this,

What i am trying to accomplish is say i got to

Copied from my browser

[localhost...]

all image locations are now

/news/view_news/images

or

/news/view_news/themes/Theme_Name

how do i fix this?

jdMorgan

1:46 am on Jun 18, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This question would be much easier to answer if we could see the mod_rewrite code that is affecting your images, and if you'd tell use what the "right" and "wrong" URLs and filepaths are (that's four separate and distinct pieces of info, there).

Jim

ioanik

9:14 pm on Jun 18, 2008 (gmt 0)

10+ Year Member



the image urls are currently either /images or /themes/ThemeName

heres some of the rewrite code i came up with

RewriteEngine on
RewriteRule ^/([A-Za-z]+)/?$ index.php?page=$1 [L,NS]
RewriteRule ^news/([A-Za-z]+)?$ index.php?page=news&func=$1 [L,NS]
RewriteRule ^news/view_news/([0-9]+)?$ index.php?page=news&func=view_news&news_id=$1 [L,NS]

ioanik

10:30 pm on Jun 18, 2008 (gmt 0)

10+ Year Member



missed my timeframe to edit...

Correct Image Urls :

images/image1.gif
images/sub/image2.gif
themes/themename/images/etc/image.gif
etc etc...

and they come up as so i load this page

[localhost...]

news/view_news/images/image1.gif

news/view_news/themes/themename/images/etc/image.gif

jdMorgan

9:52 pm on Jun 19, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So, apparently, you need to add an exclusion (RewriteCond) to each of your rules, so that images are not rewritten to the script, and to make sure that any on-page image links are to <img src="/images/logo.gif"> (server-realtive) or "http://www.example.com/images.logo.gif" (canonical) and not to "images/logo.gif" (page-relative).

Jim

ioanik

11:16 pm on Jun 19, 2008 (gmt 0)

10+ Year Member



thnx 4 the reply!