Jump to content

[SOLVED] Mod - ReWrite in HTACCESS file working but not showing images


winnard2008

Recommended Posts

Hi

 

Our programmer before he left created a url re-write using the htaccess file. This works fine but the main image on the re-written page won't show up.

 

the code for the htaccess which brings up the article is this

 

RewriteRule viewarticle/id/(.*)/ showarticle.php?id=$1
RewriteRule viewarticle/id/(.*) showarticle.php?id=$1

 

and the only two things I can see in the relevant PHP file that affect the image are as follows

 

<?PHP

  $id = $_GET['id'];//get article id
  $article = mysql_query("Select * From Articles Where articleID = '$id'");
  while($row = mysql_fetch_array($article)){//get article info
    $articleTitle = $row['articleTitle'];
$articleText = $row['articleText'];
$categoryID = $row['categoryID'];
    
switch ($categoryID){
  case 6:
        $ai = "images/photographer_article_image.jpg"; //photographers
      break;
  case 7:
        $ai = "images/wedding_dress_image.jpg"; //bridalwear
      break;
  case 10:
        $ai = "images/wedding_cake_image.jpg"; //cake makers
      break;
  case 11:
        $ai = "images/wedding_car_image.jpg"; //wedding cars
      break;
  case 16:
        $ai = "images/wedding_flowers_image.jpg"; //florists
      break;
  case 17:
        $ai = "images/wedding_venues_image.jpg"; //venues
      break;
  case 41:
        $ai = "images/catering_article_header.jpg"; //catering
      break;
  case 62:
        $ai = "images/wedding_party_image.jpg"; //entertainers
      break;
  case 57:
        $ai = "images/sports_article_image.jpg"; //fitness
      break;
  default:
    $ai = "images/wedding_venues_image.jpg"; //venues
      break;
    }//end of switch


  }//end of while loop
  
?>

 

and then further down the page where the image is supposed to appear is the following PHP code.

 

<img src="<?PHP echo $ai; ?>" alt="Wedding Advice Articles.">

 

 

The redirect make the image file location be as follows /viewarticle/id/images

 

but all the images are stored in the root /images folder.

 

 

How the hell do I get the images to appear?????

 

I am sure it is something i need to add to the htaccess file or a code error. Altho the code worked fine in PHP4.3 and now doesn't in PHP5.2.6

Link to comment
Share on other sites

this isn't an HTACCESS issue...it's just an HTML/PHP issue...

 

if you use relative paths to the images (images/wedding_dress_image.jpg) it will look for it from the current URL location. to get around this, either make your images paths absolute ones by adding a slash to the front:

/images/wedding_dress_image.jpg

or use an HTML BASE tag inside the HEAD tags of your page:

<base href="/" />

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.