winnard2008 Posted July 10, 2008 Share Posted July 10, 2008 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 https://forums.phpfreaks.com/topic/114079-solved-mod-rewrite-in-htaccess-file-working-but-not-showing-images/ Share on other sites More sharing options...
paulman888888 Posted July 10, 2008 Share Posted July 10, 2008 So you want help with PHP or .HTACCESS? I dont understand the question. Why dont you ask your old programmer Link to comment https://forums.phpfreaks.com/topic/114079-solved-mod-rewrite-in-htaccess-file-working-but-not-showing-images/#findComment-586377 Share on other sites More sharing options...
winnard2008 Posted July 10, 2008 Author Share Posted July 10, 2008 Well I aint sure whether it is the htaccess page that is causing the image not to load or the php script. Our old programmer is now uncontactable, so we are screwed. I have been a programmer for a week. Link to comment https://forums.phpfreaks.com/topic/114079-solved-mod-rewrite-in-htaccess-file-working-but-not-showing-images/#findComment-586380 Share on other sites More sharing options...
rhodesa Posted July 10, 2008 Share Posted July 10, 2008 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 https://forums.phpfreaks.com/topic/114079-solved-mod-rewrite-in-htaccess-file-working-but-not-showing-images/#findComment-586387 Share on other sites More sharing options...
winnard2008 Posted July 10, 2008 Author Share Posted July 10, 2008 LEGEND!!! Link to comment https://forums.phpfreaks.com/topic/114079-solved-mod-rewrite-in-htaccess-file-working-but-not-showing-images/#findComment-586390 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.