Getting path to images when using rewriteurl?

I’m using rewriteurl on my site so and url like this:

[B]http://mysite.com/subfolder/myname[/B]

Which is refering to:

[B]http://mysite.com/subfolder/index.php?name=myname[/B]

Now when linking to images in my script I usely do it like this:

<img src=“images/myimage.gif”>

Now the “images” folder is inside my subfolder but when running script it shows nothing and the imagelink looks like this:

[B]http://mypage.com/subfolder/myname/images/myimage.gif[/B]

How do I link to my images the normal way? Should I rewrite all my link to the images or is there an easier way?

Lucky for you there is a easier way, the HTML base tag.

i.e., put


<base href="/" />

in your HTML (see link as to where and how) :slight_smile:

Guys, IMHO it’s easier to use an (internal) absolute link to images, css, js, etc., rather than relative links OR requiring all (relative) links to be referenced to the DocumentRoot (as Rémon’s suggestion with the base tag does).

That means <img src=“images/myimage.gif”> would simple be changed to <img src=“/images/myimage.gif”>. The base tag would force the leading / but require the same treatment in the subfolder directory, too.

Regards,

DK