Problem with .htaccess and forcing https

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
kmesd62
Forum Members
Forum Members
Posts: 30
Joined: Sat Aug 06, 2011 3:17 pm

Problem with .htaccess and forcing https

Post by kmesd62 »

I am using CMSMS 2.2.12 on a site and recently upgraded the hosting to a package that came with an SSL cert.

I modded the config file and direct https requests now work fine, but when I try forcing http requests to https in the .htacess file, any browser I try the site on displays an 'err_too_many_redirects' or similar.

Here's an extract of .htaccess file:

Code: Select all

RewriteEngine on
# If your CMSMS installation is in a subdirectory of your domain, you need to specify the relative path (from the root of the domain) here.
# In example: RewriteBase /[subdirectory name]
RewriteBase /
    

# Force URLs have https instead of http
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Rewrites URLs in the form of /parent/child/grandchild but only rewrites if the requested URL is not a file or directory.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
Clearing cookies, browser cache, CMSMS cache etc. has no effect, as does hashing out the pretty url redirect.

Any thoughts appreciated. Sys info follows.

Many thanks in advance

Code: Select all

Cms Version: 2.2.12

Installed Modules:

AdminSearch: 1.0.4
AdvancedContent: 0.9.4.3
CGCalendar: 2.6.2
CGContentUtils: 2.5.3
CGExtensions: 1.64.10
CGGoogleMaps2: 1.1.1
CGSimpleSmarty: 2.2.1
CGTiny: 1.2.8
CMSContentManager: 1.1.8
CMSMailer: 6.2.14
Captcha: 1.0
CmsJobManager: 0.1.3
CustomContent: 1.9
DesignManager: 1.1.6
DownloadManager: 1.5.3
FileManager: 1.6.9.1
FilePicker: 1.0.4.1
FormBrowser: 0.5
FormBuilder: 1.0.1
Forum: 0.9.4
FrontEndUsers: 2.14.1
Gallery: 2.4
JQueryTools: 1.4.2
MenuManager: 1.50.3
MicroTiny: 2.2.4
ModuleManager: 2.1.7
NMS: 2.13.3
Navigator: 1.0.9
News: 2.51.7
Printing: 1.1.2
Search: 1.51.7
SelfRegistration: 1.14.6
ThemeManager: 1.1.8
TinyMCE: 2.9.12
TreeManager: 0.6.0
XMLMadeSimple: 0.0.6

Config Information:

php_memory_limit:
max_upload_size: 128000000
url_rewriting: mod_rewrite
page_extension:
query_var: page
auto_alias_content: true
locale:
set_names: true
timezone: Europe/London
permissive_smarty: false

Php Information:

phpversion: 7.0.33
md5_function: On (True)
json_function: On (True)
gd_version: 2
tempnam_function: On (True)
magic_quotes_runtime: Off (False)
E_ALL: 22527
E_STRICT: 0
E_DEPRECATED: 0
test_file_timedifference: A discrepancy in time with the PHP environment was detected. This may cause problems when publishing i.e. news articles.
test_db_timedifference: No time difference found
create_dir_and_file: 1
memory_limit: 128M
max_execution_time: 300
register_globals: Off (False)
output_buffering: On
disable_functions:
open_basedir:
test_remote_url: Success
file_uploads: On (True)
post_max_size: 128M
upload_max_filesize: 128M
session_save_path: /tmp (1777)
session_use_cookies: On (True)
xml_function: On (True)
xmlreader_class: On (True)
check_ini_set: On (True)
curl: On

Performance Information:

allow_browser_cache: Off (False)
browser_cache_expiry: 60
php_opcache: On (True)
smarty_cache: Off (False)
smarty_compilecheck: Off (False)
auto_clear_cache_age: On (True)
Server Information:

Server Software: Apache
Server Api: fpm-fcgi
Server Os: Linux 3.10.0-1062.4.1.el7.x86_64 On x86_64
Server Db Type: MySQL (mysqli)
Server Db Version: 10.2.29
Server Db Grants: Could not find a suitable "GRANT ALL" permission, this does not necessarily lead to problems... But if you have problems installing/removing modules or adding and deleting items/pages this could be the cause!

Permission Information:

tmp: /home/sites/6a/0/0aba8169a8/public_html//tmp (0755)
tmp_cache: /home/sites/6a/0/0aba8169a8/public_html//tmp/cache (0755)
templates_c: /home/sites/6a/0/0aba8169a8/public_html//tmp/templates_c (0755)
modules: /home/sites/6a/0/0aba8169a8/public_html//modules (0755)
uploads: /home/sites/6a/0/0aba8169a8/public_html/uploads (0755)
File Creation Mask (umask): /home/sites/6a/0/0aba8169a8/public_html//tmp/cache (0755)
config_file: 0600
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1800
Joined: Wed Feb 25, 2009 4:25 am

Re: Problem with .htaccess and forcing https

Post by DIGI3 »

I don't think it's a CMSMS issue. Some hosts have their own methods for forcing https, you might want to check with them.

To rule out cmsms, create a folder with a basic index.html and an .htaccess with the https rewrite. Temporarily rename any higher-level htaccess files as they cascade.
Not getting the answer you need? CMSMS support options
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: Problem with .htaccess and forcing https

Post by Rolf »

You might get some more pointers here:
https://cmscanbesimple.org/blog/setting ... ade-simple
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
johnboyuk1
Forum Members
Forum Members
Posts: 235
Joined: Mon Nov 26, 2018 3:09 pm

Re: Problem with .htaccess and forcing https

Post by johnboyuk1 »

If it helps, here's the code is use in my htaccess - which seems slightly different to yours

Code: Select all

RewriteCond %{ENV:HTTPS} !=on
	RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
I put it before the closing if statement for this chunk of code that's in the htaccess supplied with CMSMS

Code: Select all

<IfModule rewrite_module>
kmesd62
Forum Members
Forum Members
Posts: 30
Joined: Sat Aug 06, 2011 3:17 pm

[SOLVED] Problem with .htaccess and forcing https

Post by kmesd62 »

thanks @johnboyuk1 - worked a treat. Cheers
Locked

Return to “CMSMS Core”