Redirect issue |
Hello,
I am working on a new project with Codeigniter 4.0 beta 4. I set the URL in the configuration file: PHP Code: public $baseURL = 'http://localhost/mysite/'; If I now use a redirect, the URL will be redirected to an incorrect URL. PHP Code: return redirect()->to('/admin'); This call redirects to the following URL: http://localhost/admin I'd like someone to help me with this problem. Thanks Tom
(07-25-2019, 11:18 PM)SirTom Wrote: Hello, I assume that in this function you should specify the full path to the page including the 1st segment "mysite": Code: return redirect()->to('mysite/admin'); and in order to be able to direct to the abbreviated url addresses you need to name each of your router in this way: Code: $routes->add('{locale}/admin', 'Users::profile', ['as' => 'my_route']); and call the function: Code: redirect()->route('my_route'); I would change this world, but God doesn't give me the source.
Thank you. This solution works, BUT it seems to be a bug.
I have called the following URL: http://localhost/mySite/myController/myFunction with PHP Code: public $baseURL = 'http://localhost/mySite/'; Now i call a redirect with: PHP Code: return redirect()->back() I will be redirected to the following URL: http://localhost/myController/myFunction The URI-Element /mySite/ is missing.
(07-26-2019, 03:04 AM)SirTom Wrote: Thank you. This solution works, BUT it seems to be a bug. I think you have in the apache server settings is not installed option "root document", go to the settings in file httpd.conf and set it Code: DocumetRoot = "mySite/public" then you can redirect without substitution segment of "mySite", just typing in your browser's address bar as Code: http://localhost/myController/myFunction I would change this world, but God doesn't give me the source.
I have the same issue. It looks like CI4 cannot be installed in a subdirectory without running in redirect problems. I also think there's a bug somewhere because not all web apps will have their own domain.
I have the following config on a Windows 10 PC for local development and testing, using XAMP and CodeIgniter 4.0.0 beta 4 installed in a directory named ci4: In Apache config : Code: Alias /ci4 "/xampp/htdocs/alain/ci4/public" In ci4/public/.htaccess: Code: RewriteBase /ci4/ In ci4/app/Config/App.php: PHP Code: public $baseURL = 'http://localhost:8080/ci4/'; If I use site_url('login') or anchor('login'), it generates a valid URL to http://localhost:8080/ci4/login, but if I use route_to('login') or redirect()->back()->withInput()->with('error', lang('Auth.badAttempt')) it redirect to http://localhost:8080/login and gives a 404 error. I got those errors while testing https://github.com/lonnieezell/myth-auth
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
When did you get his Myth Auth because he updated about a month ago for the
new soft deletes etc; What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
I' am running XAMPP on Windows 10 Pro x64 1903
But I use vhost for mine. Edit C:\xampp\apache\conf\extra\httpd-vhost.conf Make sure that this is not remarked out with a #: NameVirtualHost *:80 Add this line to the bottom: Include "conf/extra/vhosts/*.conf" Create a new file called: C:\xampp\apache\conf\extra\vhosts\vhosts.conf Add this to the file and make copies of it when needed. Edit to your own setup. Code: #-------------------------------------------------------------- Now all you have to do is add the url to the Windows hosts file. Edit: C:\Windows\System32\drivers\etc\hosts you can edit it with notepad with administrator rights. Add: Code: 127.0.0.1 localhost Reboot your server and you are good to go. You can now use a base_url like https://ci3.local/ The vhost file will map everything out for you. Note: this is for testing on local machine only! What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(08-02-2019, 02:11 PM)InsiteFX Wrote: When did you get his Myth Auth because he updated about a month ago for the The same day I replied.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
(08-02-2019, 02:41 PM)InsiteFX Wrote: I' am running XAMPP on Windows 10 Pro x64 1903 Yes I know I can set up a virtual host, but that's not the point. It should work when installed in a sub directory. The framework should always use the configuration options to generate the URL's (baseURL and indexPage) and never assume it can be accessed at the root of the domain where it's installed or that you will use mod_rewrite to remove index.php.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/ |
Welcome Guest, Not a member yet? Register Sign In |