Welcome Guest, Not a member yet? Register   Sign In
Strange redirect
#1

Hello,

I'm since codeigniter2 using the framework with great joy, and now i want to upgrade my application from codigniter3 to 4 and its going well without any great problems but i found something i cant put my finger on it what the solution is.

My site is working with https behind an reverse proxy when i'm using the following url https://www.mysite.com/index.php/home/test its working fine when i have i have https://wwww.mysite.com/index.php/ then its redirect to http://mysite.com/index.php.

I have comment out the following line's in the .htaccess but its not working:


# Rewrite "www.example.com -> example.com"
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]

I have also set the variable $forceGlobalSecureRequests to false but not solution, is there somebody can help or has some advise for me where to look into this issue?

Kind regards,

whatsnow
Reply
#2

Yo! If you're behind a reverse proxy, standard methods of detecting HTTPS might not work since the request between the client and the proxy might be HTTPS, but between the proxy and your server might be HTTP.
So, first, ensure that your reverse proxy is sending an appropriate header indicating that the original request was over HTTPS. Common headers for this are X-Forwarded-Proto or X-Forwarded-Scheme.
Once you're sure the reverse proxy is sending the appropriate header, modify your .htaccess rules to check for this header instead of the default HTTPS server variable.
Let me know
Shortcode Κατασκευή Eshop + Δημιουργία Ιστοσελίδων 
Athens Greece 
Reply
#3

it might be better if you specify which version of CI 4 at the moment and how did you config in App (baseUrl)
Codeigniter First, Codeigniter Then You!!
yekrinaDigitals

Reply
#4

(This post was last modified: 08-13-2023, 02:21 AM by whatsnow.)

(08-12-2023, 11:57 PM)luckmoshy Wrote: it might be better if you specify which version of CI 4  at the  moment  and how did you config in App (baseUrl)

Thankyou for your response, I'm using version 4.3.6, my base url is:



 
PHP Code:
public string $baseURL 'https://www.mysite.com/';
/**
    * Allowed Hostnames in the Site URL other than the hostname in the baseURL.
    * If you want to accept multiple Hostnames, set this.
    *
    * E.g. When your site URL ($baseURL) is 'http://example.com/', and your site
    *      also accepts 'http://media.example.com/' and
    *      'http://accounts.example.com/':
    *          ['media.example.com', 'accounts.example.com']
    *
    * @var string[]
    * @phpstan-var list<string>
    */
    public array $allowedHostnames = ['mysite.com']; 

Kind regards,

Whatsnow
Reply
#5

Thankyou i’m going to check my reverse proxy
Reply
#6

(This post was last modified: 09-21-2023, 04:54 AM by whatsnow.)

My problem is solved, i have removed the reverse proxy it was causing this issue.

I have read the manual 10 times about it and couldnt find my solution.
Reply
#7

(09-21-2023, 04:39 AM)whatsnow Wrote: My problem is solved, i have removed the reverse proxy it was causing this issue.

I have read the manual 10 times about it and couldnt find my solution.

Could you kindly outline the process you followed to resolve it? My URL, when including a slash (/), continues to redirect to one without it. I've been experimenting with the .htaccess file, but so far, no solution seems to be work  Confused
Reply
#8

[quote pid="411718" dateline="1691835104"]
when i have i have https://wwww.mysite.com/index.php/ then its redirect...

[/quote]
There is a typo in this URL (4 "w"). It's just in the post or in your code too?
Just my 0.02...

Best regards
Reply




Theme © iAndrew 2016 - Forum software by © MyBB