CodeIgniter Forums
url brocken / become /2F - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: url brocken / become /2F (/showthread.php?tid=86576)



url brocken / become /2F - cb21 - 02-04-2023

I upgraded from CI4.1 or 2 (not sure) to CI4.3
I install a fresh installation and copy views, models controllers etc...

I noticed that lot of change break the code specialy the url. Before I had site_url('controller/method') but the url became like
?%2Fen%2Fgestion%2Flogin%2Flogincheck= / --> %2F I notice I have a ? added and = at the end. 
My solution was to replace site_url by base_url and my / stay /
Now I still have the problem with form_open
Example   echo form_open("/login/logincheck");
--> %2Flogin%2Flogincheck=
How to keep url correctly as I want not as codeigniter wants.
Where do I know all code I need to change like site_url is not valid but replaced by base_url

Maybe I just have to find the correct parameter and all will works as before in previous version.


RE: url brocken / become /2F - kenjis - 02-04-2023

I cannot reproduce:
PHP Code:
<?php

namespace App\Controllers;

class 
Home extends BaseController
{
    public function index()
    {
        helper('form');
        return form_open("/login/logincheck");
    }

I see <form action="http://localhost:8080/index.php/login/logincheck" method="post" accept-charset="utf-8">


RE: url brocken / become /2F - cb21 - 02-04-2023

The version is from this morning 
I installed it with composer
Maybe my configuration has something wrong


RE: url brocken / become /2F - cb21 - 02-04-2023

My source code looks like
<form action="http://localhost/../index.php?%2Fgestion%2Flogin%2Flogincheck=" method="post" accept-charset="utf-8">

I found a workaround

// echo form_open('gestion/login/logincheck');
$url = base_url('index.php/gestion/login/logincheck');
echo form_open($url);

base_url give me good url
form_open --> wrong url
site_url -->wrong url. I have to change all site_url I had in base_url

Waiting for advice...


RE: url brocken / become /2F - kenjis - 02-04-2023

Did you change Config files?

The base_url() and site_url() uses the same code in most of the part.
I don't know why site_url() outputs URL encoded values.


RE: url brocken / become /2F - cb21 - 02-05-2023

@kenjis do you think I have a wrong version and I should reinstall CI 4.3.1 properly ? I started to change the code but if you say that should not be like this now I doubt that something is wrong in my installation


RE: url brocken / become /2F - kenjis - 02-05-2023

(02-04-2023, 02:58 AM)cb21 Wrote: I upgraded from CI4.1 or 2 (not sure) to CI4.3
I install a fresh installation and copy views, models controllers etc...

You installed v4.3.1 and copied your views, models controllers etc.
Did you change the Config files?
If you changed the Config, it might cause your issue.

But as I wrote, site_url() and base_url() use almost same code.
So I think it is not likely to be.

What if you install clean v4.3.1 and run?
PHP Code:
echo form_open('gestion/login/logincheck'); 



RE: url brocken / become /2F - cb21 - 02-11-2023

What if you install clean v4.3.1 and run?
PHP Code:
echo form_open('gestion/login/logincheck');

--> 
Reinstallation a clean new CI4.3.1 and it worksI don't know what was the cause of this problem but now I can upgrade all my application properly. Thank you for your support.

This subject can be close as resolved 



RE: url brocken / become /2F - InsiteFX - 02-12-2023

Some times you may get a bad CodeIgniter download, has happened to me several times in the pass.