by
KK » Wed Feb 22, 2012 10:49 pm
Hi Mark,
This actually is a problem that is not specific to Couch. You'll come across it where-ever you use prettyURLs (i.e. mod_rewrite).
This happens when your templates use relative paths for images/CSS/scripts instead of absolute ones.
It is rather easy to see why this happens -
Suppose this is your page's URL before using prettyURL
http://www.yoursite.com/mypage.php?p=12
and within it is an image that goes something like this
<img src="images/myimg.gif" />
It is easy to see that the browser resolves the path of the image relative to the page it is on and it comes to (correctly):
http://www.yoursite.com/images/myimg.gif
Now consider what happens when we turn on prettyURL. The URL of the page now becomes
http://www.yoursite.com/mypage/something.html
Now the path of the image gets resolved to
http://www.yoursite.com/mypage/images/myimg.gif
Can you see what is happening? That 'mypage' folder is actually non-existent physically and ergo why the image is lost.
To rectify this problem you'll have to use absolute paths so that those are resolved independently of the page's URL.
Thus you could either use
<img src="/images/myimg.gif" />
- notice the '/' before 'images' that stands for the root of your site
or use
<img src="<cms:show k_site_link />images/myimg.gif" />
in this case we are explicitly outputting the site's URL.
Hope this helps.