News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

http and https mixed in boards and buttons

Started by Fisch.666, July 30, 2011, 07:17:14 PM

Previous topic - Next topic

Fisch.666

Hi!

I'm trying to offer non-ssl and ssl access to my forums. For this i have read this post:

http://www.simplemachines.org/community/index.php?topic=414054.msg2912994#msg2912994

added the forum_alias_urls setting with the given file and cleaned the cache. Now i still have mixed http:// and https:// content in my forum:

https://www.prielwurmjaeger.de/forum/index.php?action=community

Some boards have the https:// but most of them have the http:// prefix and all of the buttons (like start a new thread or answer) have the http:// prefix (instead of https://)

I don't know where to search for this problem, hope someone can help me with this or give me a hint where to start.

Thanks in advance for a reply

Software:
SMF 2.0 Final
Portamx 1.4 (i have the same problem on a board which isn't running portamx)
PrettyUrls 1.0RC5.2 (don't know if this will cause this problem)

Fisch.666

Hi,

forgot to post the status of this here. According this post:

http://www.simplemachines.org/community/index.php?topic=146969.msg3229987#msg3229987

it seems that PrettyUrls is the source of this problem. If there is no https support from PrettyUrls this problem can't be solved.

ziycon

As far as I know it doesn't support https. With that said prettyurls wont do much for you're forum apart from have nice looking urls, it's not going to have a major effect if any on search engine rankings or SEO.

Fisch.666

#3
Hi,

i had some time and did some further research about this and was able to fix my problem. Any comments about this are welcome.

PrettyURLs is using a fixed pretty_root_url like http://www.example.com (from the smf_settings table in the db) to create the urls. That's the reason why the urls had the missing https:// in front of the urls.

What i did was:

Open Settings.php

1. Find and comment out:
$boardurl = 'http://www.example.com/forum';           # URL to your forum's folder. (without the trailing /!)

2. After add:

if ( empty($_SERVER['HTTPS']) ) {
    $boardurl = 'http://www.example.com/forum';
} else {
    $boardurl = 'https://www.example.com/forum';
}


Open forums/Sources/PrettyUrls-Filters.php

1. Search for:

function pretty_urls_topic_filter($urls)


2. Search in this function for:

global $context, $modSettings, $scripturl, $smcFunc, $sourcedir;


and replace with:


global $boardurl, $context, $modSettings, $scripturl, $smcFunc, $sourcedir;


3. Search for:


$urls[$url_id]['replacement'] = $modSettings['pretty_root_url'] . '/' . $topicData[$url['topic_id']]['pretty_board'] . '/' . $topicData[$url['topic_id']]['pretty_url'] . '/' . $start . $url['match1'] . $url['match3'];


and replace with:


$urls[$url_id]['replacement'] = $boardurl . '/' . $topicData[$url['topic_id']]['pretty_board'] . '/' . $topicData[$url['topic_id']]['pretty_url'] . '/' . $start . $url['match1'] . $url['match3'];


4. Search for:


function pretty_urls_board_filter($urls)


5. Search in this function for:


global $scripturl, $modSettings, $context;


and replace with:


global $boardurl, $scripturl, $modSettings, $context;


6. Search for:


$urls[$url_id]['replacement'] = $modSettings['pretty_root_url'] . '/' . (isset($context['pretty']['board_urls'][$board_id]) ? $context['pretty']['board_urls'][$board_id] : $board_id) . '/' . $start . $matches[1] . $matches[3];


and replace with:


$urls[$url_id]['replacement'] = $boardurl . '/' . (isset($context['pretty']['board_urls'][$board_id]) ? $context['pretty']['board_urls'][$board_id] : $board_id) . '/' . $start . $matches[1] . $matches[3];


With that changes the mixed content is gone. If you have multiple domains running which are pointing to the same forums you should also make the changes to your Settings.php like described here:

http://www.simplemachines.org/community/index.php?topic=125902.msg805462#msg805462

vbgamer45

For reference here is quick script to change the pretty url internal main url

<?php
require_once(dirname(__FILE__) . '/SSI.php');
require_once(
$sourcedir '/Subs-PrettyUrls.php');
updateSettings(array('pretty_root_url' => $boardurl));
pretty_update_filters();
?>



Replace $boardurl with the url you want to use.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Fisch.666

Ok, thanks for this info.

But this only fixes such an issue when you're switching your board from http to https (or from https to http) and want to change this once. If you want to provide http and https access you have to use my provided solution above.

Advertisement: