Forum Moderators: phranque

Message Too Old, No Replies

why i could not display a image?

why i could not dispaly a image?

         

xbl01234

5:31 am on Dec 15, 2007 (gmt 0)

10+ Year Member



Hi;
i am trying to display a image, but why i could not do that, is it the problem that i use the mod_rewrite
rule?

The following is my work

.htaccess
RewriteEngine On
RewriteRule ^([a-z]+)/([0-9]+)/$ /dispaly.php?page=$1 [L]

index.php

<html>
<body>

Welcome to my page. <br>
<a href="image/1"> go to another page </a>

</body>
</html>

display.php

<html>
<body>
<img src="boat.gif" alt="Big Boat">
</body>
</html>

jdMorgan

4:08 pm on Dec 15, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Remember that it is the client (browser or search engine robot) which resolves relative URLs in links on your pages. Because the browser thinks the page URL is (for example) "/directory/1234/", a relative link using "<img src="boat.gif" will be resolved to "example.com/directory/1234/boat.gif".

There are two ways to fix this. The first is to use server-relative or canonical links for included objects:


<img src[b]="/b[/b]oat.gif" alt="Big Boat">

-or-
 <img src="http://www.example.com/boat.gif" alt="Big Boat">

The second is to rewrite relatively-linked image requests back to the correct location:

.htaccess

RewriteEngine on
#
RewriteRule ^([a-z]+)/([0-9]+)/$ /display.php?page=$1 [L]
#
RewriteRule ^[a-z]+/[0-9]+/([^.]+\.(gif¦jpe?g¦png¦bmp))$ /$1 [L]

Warning: This new rule creates duplicate content -- The same images will be available at more than one URL. However, this may not be of major concern unless you are trying to rank well in image search engines.

Replace all broken pipe "¦" characters in the code with solid pipes before use; Posting on this forum modifies the pipe characters.

Jim

xbl01234

10:53 pm on Dec 15, 2007 (gmt 0)

10+ Year Member



Thanks for your time, it is very help full.