Problems, need help? Have a tip or advice? Post it here.
8 posts Page 1 of 1
Hi,

I recently turned on Pretty Urls for a site I am working on and this worked OK apart from one issue. All the links to images and stylesheets were broken on all pages.

Do you have any idea what could be causing this?

Many thanks,

Mark
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.
Thanks, I will try that and get back to you.

Regards,

Mark
I think I'm having the same issue with my site, it's loading styles for one page only(the index page) and the rest are all broken.

When I click on the actual link it goes to mysite.com/test/blog/blog. Then everything is broke.
You can always make use of the web developer tools/console in your browser. They can be extremely helpful for monitoring http requests. In this situation you would look for the 404s. Firefox and Chrome are excellent in this regard.
OK, I have fixed the images and style sheets, but I now get the following problem.

I have a menu on each page as follows:

Code: Select all
<ul id="main">
      <li class="current_page_item"><a href="/index.php">Homepage</a></li>
      <li><a href="about.php">About Me</a></li>
      <li><a href="achieve.php">Achievements</a></li>
      <li><a href="links.php">Useful Links</a></li>
      <li><a href="contact.php">Contact Us</a></li>
   </ul>


Now, when I try and go to, say, the about page (about.php) I get a 404 error saying "/about/ cannot be found on this server".

Should I change these links to be:

Code: Select all
<li><a href="/about/">About Me</a></li>


?

Many thanks,

Mark
Hi,

Instead of hard-coding template names as in
<a href="about.php">About Me</a>

it is always better to use
<a href="<cms:link 'about.php' />">About Me</a>

where cms:link outputs the appropriate URL depending on whether or not prettyURLs are being used.

Having said that, with prettyURLs on, even if you access a page using the original URL e.g. about.php, Couch should take care to redirect you to the new URL.
So, the error "/about/ cannot be found on this server" is intriguing.

Are you sure you have generated the required .htaccess and placed in your site's root?
There should be an entry for 'about.php' in this file.
In case your site happens to be running from a sub-folder, have you set this in the .htaccess file?

If you still have trouble, kindly PM me your site's FTP creds and I'll try and find the problem.
Thanks.
I'm an idiot :oops: I went back and updated the links but forgot to re-do the .htaccess step. It works perfectly now.

Many thanks again!

Mark
8 posts Page 1 of 1