Forum for discussing general topics related to Couch.
5 posts Page 1 of 1
Hi,

I am moving to https soon.

Is there a way to move all the internal links from http to hhtps, beside a crude 301?

I mean, I don't want to change them all manually, as they are already in the DB.
I know I can Search and replace in the DB, but still...

If anybody knows a better way with Couch? That might be useful.

Sorry if I seem dumb.

Cheers,
Paolo
Hi Paolo,

There are two types of links you'll come across -

1. Links generated by Couch code (e.g. using <cms:show k_page_link />, <cms:show k_site_link /> or links of 'image', 'thumbnail', 'file' editable regions etc.).
You don't need to do anything to get these to switch over to https. They'll automatically sense that the site is using https:// and output that in the links (in rare cases, when this does not happen automatically, you can set an explicit https:// URL in Couch config to force the CMS to use the new URL).

2. Links which are hard-coded e.g. within HTML source or (and perhaps this is what you meant) within the contents of 'richtext' editable regions. For the former, you'll have to modify the template code whereas for the latter finding and replacing all URLs in a database dump is a reasonable solution.

Hope this reply helps.
As I've done this a number of times over the past year, I'll share what I've done:

• Set up your SSL cert and stuff with your host.

• Turn off caching for the time being in config.php

• Do a find and replace in all your template files / css files for any accidentally hardcoded URLS. Replace with <cms:show k_page_link /> <cms:show k_site_link /> if possible. Push those live, along with config.php.

• Spot check to make sure you didn't screw anything up so far. This will let you know that these changes aren't the problem if there are problems later.

• Go to phpmyadmin in your host and export the DB to your computer.

• Copy this file somewhere else just in case you screw everything up - I like a USB drive so I don't get anything confused.

• Rename the file you will be adjusting to "[sitename]-database-http-to-https-[date]" or something.

• Open this renamed file in your text editor

• Find and replace http://site.com http://www.site.com and https://site.com with https://www.site.com (note: if you are not using www, then adjust). Be sure to replace it only what is necessary and don't **** up the trailing slash. ;)

• Go back to phpmyadmin and export the db AGAIN. Backups will save your grace if something goes wrong.

• Go back to the browse section of phpmyadmin and drop your DB (That you have multiple backups of now). Don't drop any DB except the one you have backups of!

• Go to import in phpmyadmin and select your "[sitename]-database-http-to-https-[date]" file.

• Turn on / update your 1. define( 'K_SITE_URL', 'https://www.site.com/' ); in config.php

• Open an incognito window or different browser (301 redirects are heavily cached by browsers - moreso than your typical CSS file) and check to make sure everything is working. [/list]

If anything ISNT working:

• first step is to make sure you are logged into Couch as superadmin and go save a few pages in the couch admin / backend.

• If you are getting "too many redirects" use a service like http://www.redirect-checker.org/ to check the problematic URL. This ensures that it's a real issue and not a local-browser-caching-issue. (I spent 3 hours debugging a non-issue because my browser cached it in Chrome and Couch had cached something and I wasn't logged in incognito. >,< )

• Breath

• Check more things

• Drop the DB and replace with your backup, delete your edited DB file, and start over.


htaccess to enforce www / https (I'm no expert but this is the best combo that I've been able to find)
Code: Select all
RewriteCond %{HTTP_HOST} !^www\. [OR]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.site.com%{REQUEST_URI} [L,R=301]
Thanks @tmo :)

For anyone chancing upon this thread later, regarding the "too many redirects" mentioned by @tmo please see viewtopic.php?f=4&t=10825#p27593
Don't know if this might help anyone, but I had a VERY easy time when I moved to HTTPS
I simply updated the site URL in the Couch config.php file,
then added this .htaccess file to my site root directory:
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

No guarantees offered obviously, but it worked like a dream for me - all images etc found via HTTPS, no SSL warnings at all.
5 posts Page 1 of 1
cron