Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
5d370c7e
Commit
5d370c7e
authored
12 years ago
by
Laurent Destailleur
Browse files
Options
Downloads
Patches
Plain Diff
Fix: force redirect to https could not work for some environments
parent
0128cc36
Branches
solution
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
htdocs/conf/conf.php.example
+5
-2
5 additions, 2 deletions
htdocs/conf/conf.php.example
htdocs/main.inc.php
+9
-4
9 additions, 4 deletions
htdocs/main.inc.php
with
14 additions
and
6 deletions
htdocs/conf/conf.php.example
+
5
−
2
View file @
5d370c7e
...
@@ -198,10 +198,13 @@ $dolibarr_main_authentication='dolibarr';
...
@@ -198,10 +198,13 @@ $dolibarr_main_authentication='dolibarr';
// dolibarr_main_force_https
// dolibarr_main_force_https
// This parameter allows to force the HTTPS mode.
// This parameter allows to force the HTTPS mode.
// 0 = No forced redirect
// 1 = Force redirect to https until SCRIPT_URI start with https
// 2 = Force redirect to https until SERVER["HTTPS"] is 'on'
// Warning: If you enable this parameter, your web server must be configured
// Warning: If you enable this parameter, your web server must be configured
// to respond URL with https protocol.
// to respond URL with https protocol.
// Default value: 0
// Default value: 0
// Possible values: 0 or
1
// Possible values: 0
, 1
or
2
// Examples:
// Examples:
// $dolibarr_main_force_https='0';
// $dolibarr_main_force_https='0';
//
//
...
...
This diff is collapsed.
Click to expand it.
htdocs/main.inc.php
+
9
−
4
View file @
5d370c7e
...
@@ -196,9 +196,9 @@ if (isset($_SERVER["HTTP_USER_AGENT"]))
...
@@ -196,9 +196,9 @@ if (isset($_SERVER["HTTP_USER_AGENT"]))
if
(
!
empty
(
$conf
->
file
->
main_force_https
))
if
(
!
empty
(
$conf
->
file
->
main_force_https
))
{
{
$newurl
=
''
;
$newurl
=
''
;
if
(
$conf
->
file
->
main_force_https
==
'1'
)
if
(
is_numeric
(
$conf
->
file
->
main_force_https
)
)
{
{
if
(
!
empty
(
$_SERVER
[
"SCRIPT_URI"
]))
// If SCRIPT_URI supported by server
if
(
$conf
->
file
->
main_force_https
==
'1'
&&
!
empty
(
$_SERVER
[
"SCRIPT_URI"
]))
// If SCRIPT_URI supported by server
{
{
if
(
preg_match
(
'/^http:/i'
,
$_SERVER
[
"SCRIPT_URI"
])
&&
!
preg_match
(
'/^https:/i'
,
$_SERVER
[
"SCRIPT_URI"
]))
// If link is http
if
(
preg_match
(
'/^http:/i'
,
$_SERVER
[
"SCRIPT_URI"
])
&&
!
preg_match
(
'/^https:/i'
,
$_SERVER
[
"SCRIPT_URI"
]))
// If link is http
{
{
...
@@ -215,9 +215,14 @@ if (! empty($conf->file->main_force_https))
...
@@ -215,9 +215,14 @@ if (! empty($conf->file->main_force_https))
}
}
}
}
else
else
{
// Check HTTPS environment variable (Apache/mod_ssl only)
// $_SERVER["HTTPS"] is 'on' when link is https, otherwise $_SERVER["HTTPS"] is empty or 'off'
if
(
empty
(
$_SERVER
[
"HTTPS"
])
||
$_SERVER
[
"HTTPS"
]
!=
'on'
)
// If link is http
{
{
$newurl
=
$conf
->
file
->
main_force_https
.
$_SERVER
[
"REQUEST_URI"
];
$newurl
=
$conf
->
file
->
main_force_https
.
$_SERVER
[
"REQUEST_URI"
];
}
}
}
// Start redirect
// Start redirect
if
(
$newurl
)
if
(
$newurl
)
{
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment