Problems, need help? Have a tip or advice? Post it here.
10 posts Page 1 of 1
hi, I seem to make a bit of work for myself on deploying a site from localhost to a server on going live with regard to file paths - particularly images. Some of the images on the site are not defined as editable fields and uploaded via Couch - but were simply put into a file named 'img' - hence a path of img/image-name.jpg which works fine on localhost. These images may be referrred to in the HTML or CSS files.

But when I move a site live I have to add the prefix of '/' for the path to continue to work (or add <cms:show k_site_link />). A similar thing also applies to javascript files - placed in a folder named 'js'.

Is there any other way of allowing a seamless transition from localhost i.e. not having to change paths? Do I have to declare an editable field of img type and upload the images and then reference them by name with <cms:show image_name /> for this to happen?

There are some images in the site that I don't expect or want the client to access (e.g. site logo, background images and so on).

Yours, slightly confused!
Hi Potato,

To be fair, this is not a Couch related problem - you'll have the same problem had your template been a static HTML one.

What beats me, however, is why a relative path that worked well on localhost break on a different server? If you have retained the same folder structure across the two servers all the relative paths should resolve properly on both places.
Have you turned on prettyURL on the live site? This is one scenario where relative paths became a real pain.

As for the resolution - the paths of the images and js/css files that you mention are hardcoded into your templates so it shouldn't take long to hunt for these elements and add the '/' or <cms:show k_site_link /> before each.

You certainly do not need to create an editable region for these kind of assets. I think if you just make sure not to use relative paths in your templates, you'll never have to face this problem.

Incidentally, this is also where the practice of using cms:embed for headers, footers etc. proves its advantage - just a single file to edit.
In the past I have switched on pretty URLs on going live - so this has no doubt added to the confusion.

I'm now trying to switch pretty urls on this new site I'm working on on localhost to see if this is a good way to work. Try as I might (& I've looked at other postings on this topic) I cannot get it working.

The site is at C:/wamp/www/sitefolder and I've generated the .htaccess file and placed it in C:/wamp/www/sitefolder

I can get to the home page - localhost/sitename/ but any other pages return an error:

The requested URL /sitename/books/ was not found on this server.


Have I done something obviously daft here?
I trust the prettyURLs are working well on the live server (except for the img/css links that go awry) but not on the localhost, right?

I see that your site is in a sub-folder C:/wamp/www/sitefolder.
1. Have you added this subfolder's info to the .htaccess file generated?
You'll find the following line that needs amendment in .htaccess file -
#If your website is installed in a subfolder, change the line below to reflect the path to the subfolder.
#e.g. for http://www.example.com/subdomain1/subdomain2/ make it RewriteBase /subdomain1/subdomain2
RewriteBase /

2. Can you please confirm that the documentroot (i.e. C:/wamp/www/) does not contain a previous .htaccess of its own that is clashing with the one placed in C:/wamp/www/sitefolder?
If there is one, try removing it temporarily.

Please let me know if this helps.
hi again ... yes, pretty urls have always worked fine when I've switched them on going live with a Couch site.

Yes I've added the path to the RewriteBase / in .htaccess i.e.
Code: Select all
RewriteBase /C:/wamp/www/sitefolder 

I've also tried other paths like localhost/sitefolder - but am still getting pages not found.

There are no other .htaccess files in C: or wamp or www

I realise this is tricky as you cannot see what is happening on my machine (and it may be something strange going on) ... so unless there is something else obvious to try I'll stop taking up your time and switch off the pretty urls - and go back to my usual way of switching them on when the site goes live.

Thanks!
I think you are making a little mistake somewhere in adding the subfolder to .htaccess.
The key here is the URL of your site as accessed on the localhost (as opposed to its physical path). For example, if this is how you access the home page of your Couch managed site -
http://localhost/sitename/

- the following would be the correct entry in .htaccess
RewriteBase /sitename

there is no space after the '/' and there is no trailing slash.

Please try this and let me know if it helps. Thanks.
mmmm ... no joy I'm afraid. I changed the RewriteBase as you said and I still only get the home page ... other pages are not found. So the message is displayed:
The requested URL /sitename/books/ was not found on this server.
when the file /sitename/books.php does exist and can be accessed OK with pretty urls off.

Please don't spend any more of your time on this ... and thanks! :(
Always difficult to let go of a problem without getting it resolved :)
Unfortunately, in this case the installation is local to your machine and hence there is little I can do myself.
yes I agree, I'm like a dog with a bone - stubborn and hate giving up!! But on this occasion pragmatism wins the day ... ;)
10 posts Page 1 of 1