SSL and relative urls

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
peterasap
New Member
New Member
Posts: 5
Joined: Wed Dec 31, 2014 8:15 am

SSL and relative urls

Post by peterasap »

Hello,

We are about to move our site on SSL and I was wondering if there is guide I can read with helpful tips or something ?

The problem I am facing at the moment is that most of the urls are absolute i.e

Code: Select all

<a href='http://www.example.com/somelink.html'>Link</a>
while I want it to be:

Code: Select all

<a href='/somelink.html'>Link</a>
For menus I found this:

http://forum.cmsmadesimple.org/viewtopi ... =8&t=15441

However for News module I have found nothing ?

Any hint, ideas and general directions on using relative urls will be appreciated.

Thanks,

Peter
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: SSL and relative urls

Post by velden »

I don't think the urls need to be relative as cmsms will dynamically create those absolute urls depending on the current url and protocol used.

Read the pdf about config.php that comes in the /docs folder of the cmsms install. There are some config settings to enable SSL for frontend as well as backend (admin). Personally I don't have any experience with this.

About searching the form: iirc it doesn't search for keywords <4 characters. So 'ssl' won't give results.

Though Google will do fine: https://www.google.nl/search?q=ssl+site ... simple.org
peterasap
New Member
New Member
Posts: 5
Joined: Wed Dec 31, 2014 8:15 am

Re: SSL and relative urls

Post by peterasap »

Hi,

We call the news module in this way:

Code: Select all


               {news category="Popular courses" summarytemplate="Popular-home" number="8" detailtemplate="popular"}

Unfortunately, news modules does not create links with SSL i.e it creates absolute plain HTTP links. If needed I can make a patch in the module, but was hoping for a simpler solution that does not require change in PHP code as it will break during upgrades...
peterasap
New Member
New Member
Posts: 5
Joined: Wed Dec 31, 2014 8:15 am

Re: SSL and relative urls

Post by peterasap »

I solved the problem myself.

In case someone have it:

Open config.php and replace

Code: Select all

$config['root_url'] = 'http://www.example.com';  
with

Code: Select all

//$config['root_url'] = 'http://www.example.com';  
if($_SERVER['SERVER_PORT']=='443'){
  $config['root_url'] = 'https://www.example.com';  
}else{
   $config['root_url'] = 'http://www.example.com';    
    
}
Peter
Post Reply

Return to “The Lounge”