Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redirect #151

Closed
mostafakhudair opened this issue Dec 30, 2019 · 17 comments
Closed

redirect #151

mostafakhudair opened this issue Dec 30, 2019 · 17 comments

Comments

@mostafakhudair
Copy link

I face a problem with redirects, when I clock on Login its redirect to from http://localhost/appstarter/public/login to http://localhost/login and nothing happens and when I click on Need an account? it just redirect to http://localhost/register not http://localhost/appstarter/public/register

@MGatner
Copy link
Collaborator

MGatner commented Dec 30, 2019

It sounds like your hosted folder and base URL and not synced up correctly. Make sure you are serving the public/ folder and that your base URL is set to reflect any subdirectories (https://codeigniter4.github.io/userguide/installation/running.html)

@mostafakhudair
Copy link
Author

Everything is running very well in my app.Controllers redirect route_to works very fine, my problem when i try to use links within myth/auth login/register/forgot/etc... It doesn't work

@MGatner
Copy link
Collaborator

MGatner commented Dec 30, 2019

Those are all named routes so work a little different than route_to(). Are you using the latest development build of the framework? There have been quite a few changes to URL handling that also affect redirects - it's a good place to start.

@mostafakhudair
Copy link
Author

I'm using CodeIgniter v4.0.0-rc.3, and latest Myth version
app.Controllers/Home
href="" redirect to Tasks controller
but in app.ThirdParty/Myth/Auth/Views .. it's redirect to nothing i'm a bit confused about this problem

@MGatner
Copy link
Collaborator

MGatner commented Dec 30, 2019

If you don't mind, please try the latest development branch of codeigniter4/codeigniter4 as the URL changes I referenced have been made since RC3 (e.g. codeigniter4/CodeIgniter4#2407)

@mostafakhudair
Copy link
Author

I tried it and i face the same problem,, it's base_url works fine but after I submit login form it's redirect to http://localhost/login then I click on browser Back button to take me back to http://localhost/codeigniter4/public/login and see validation errors or logged in successfully

@MGatner
Copy link
Collaborator

MGatner commented Dec 31, 2019

@mostafakhudair Could you please share your $baseURL and $indexPage settings (from .env or app/Config/App.php) and hosting engine (e.g. Apache, spark, Nginx)? And your code that makes the link in your example ("I click on login...")?

@InsiteFX
Copy link

This sounds like a base url problem because everything works fine on my system.

@mostafakhudair
Copy link
Author

.env
app.baseURL = http://localhost/appstarter/public/
app.indexPage = ''
Apache

Myth\Auth\Config Routes.php $routes->group('', ['namespace' => 'Myth\Auth\Controllers'], function($routes) { $routes->get('login', 'AuthController::login', ['as' => 'login']); });

@MGatner
Copy link
Collaborator

MGatner commented Jan 1, 2020

It looks like you are serving the directory above the project root and then trying to adjust the baseUrl to fit it. If you have Apache access, set it to serve appstarter/public as the root; if you don't have access you could try accomplishing the equivalent configuration with .htaccess files - there are lots of resources on the forums for this.

@rhubka
Copy link

rhubka commented Jan 4, 2020

I'm having the exact same issues with CI4 RC3 - windows 10 running Laragon
Welcome to CodeIgniter is here:
http://localhost/ci4_test/public/
Composer installed myth-auth to:
C:\laragon\www\ci4_test\vendor\myth\auth
So my $psr4 is
'Myth\Auth' => ROOTPATH . 'vendor\myth\auth\src'
I get the login page with this URL:
http://localhost/ci4_test/public/login
Then When I click the "Need an Account" link it goes here:
http://localhost/register
but the real Register page is here:
http://localhost/ci4_test/public/register
If I enter data in register it does not cut a row in the user table and sends me here:
http://localhost/register

Any suggestions. Maybe a completed zipped install that works that I can try?

@MGatner
Copy link
Collaborator

MGatner commented Jan 4, 2020

@rhubka it sounds like you have the same server misconfiguration. You should be serving public as the web root, and setting your base URL accordingly. If you can’t adjust the server settings you will need to use an htaccess file to adjust.

@agungsugiarto
Copy link
Contributor

@rhubka try this:

php spark serve

or like this:

php -S localhost:8080 -t public

@skechav
Copy link

skechav commented Jan 7, 2020

I can confirm that myth-auth is working as expected both on SSL and non SSL local server configuration (Xampp). But I also need to say that I have made a composer install of both Codeigniter and Myth-auth library.
I 'm using myth/auth version: 1.0-beta.2 and Codeigniter version : v4.0.0-rc.3
I also faced this (normal) behaviour before configuring virtual hosts for my local apache host.
The sure thing is that it needs carefull configuration both for local server and application.

@mostafakhudair If you are using, for example, a xampp installation for local server and you have your codeigniter application files copied, lets say, under C:\xampp\htdocs\yourapplicationrootfolder then try configuring a virtual host so you can overcome the problem you have mentioned, like this :

  1. First, locate your windows system hosts file under C:\Windows\System32\drivers\etc\hosts and open it with an editor with admin rights .Then add something like this :
    127.0.0.1 yoursubdomain.domain.com

  2. Then locate your local servers' virtual hosts configuration file httpd-vhosts.conf under C:\xampp\apache\conf\extra and add this :

                    <VirtualHost *:80>
                            DocumentRoot    "C:/xampp/htdocs/yourapplicationrootfolder/public"
                            ServerName      yoursubdomain.domain.com
                     </VirtualHost>
  1. Go to C:\xampp\htdocs\scmanage\app\Config\App.php open it and set
    public $baseURL = 'http://yoursubdomain.domain.com;
    I can't go in deeper details cause I m in a hurry but this the basic proccess. Search the web how to configure a virtual host on windows xampp installation (I made a guess about Windows)..

Good Luck!!
(Sorry for posting a kind of tuttorial here , in case you want me to delete it just let me know )

@fefo-p
Copy link
Contributor

fefo-p commented Jan 7, 2020

In your DocumentRoot directive, there's a blank space before /public that should not be there

@skechav
Copy link

skechav commented Jan 7, 2020

@fefo-p Yes indeed and thanks for nothing that! It was very late at night and I ve been fast and furious😜. I removed that space. Anyway it was a general example just to help him getting started with virtual hosts..

@mostafakhudair
Copy link
Author

problem solved @skechav that was a brilliant solution, thanks for the tutorial.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants