Where can i set the redirect path when session timeout? If i am not mistaken, by default, laravel will redirect to /login but instead of this, I want to redirect to something like this /admin/login. Is there any way to do this?
I think you are looking for function unauthenticated() located at : app/Exceptions/Handler.php
Related
I've created the basic application used make:auth
I then renamed HomeController to MembersController
When assessing the controller it redirect to the home page but it only does this when
//$this->middleware('auth');
isn't commented. It works fine when uncommented, with the exception theres no authorization.
Any ideas on why its behaving this way
Go to app/Http/Middleware/Authenticate.php then change the redirect URL,where you want to redirect after login
My web app needs to redirect user to an external website using
redirect()->away($url).
However, this won't work if url does not contain "http://" or "https://". Because the url is user defined, I don't think it's a good way to manually add "http://" or "https://". Is there any way in Laravel that can be used to redirect user to external website without need to add "http(s)://"?
There is nothing in Laravel that will force the $url passed to away() to be an external url. Using away() is so Laravel doesn't force it to be an internal url.
You can use parse_url to check if the HOST portion exists. If it does, it is an absolute URL and will redirect as you expect. If it doesn't, add a '//' to the beginning of the redirect url, so it will redirect away.
redirect()->away((is_null(parse_url($url, PHP_URL_HOST)) ? '//' : '').$url);
Note, check the HOST, and not the SCHEME. If the user enters `//google.com', this is correct and will redirect as expected, but the scheme is empty.
Or, as #Thomas suggests, use validation to force the user to enter an absolute url.
Yes, force the user to enter it with a simple regex validation rule: 'url' => 'regex:#^https?://#'.
I am using laravel 5.1 and I am trying to make it possible for users to log in to my app. I'm doing this in xampp, so my login path looks like this: http://localhost/laravel/public/index.php/auth/login.
However, when I try to log in it redirects me to http://localhost/auth/login and gives a 404 error. It does this too when the login fails. I have tried to set the 'protected $redirectPath' and 'protected $loginPath' in the AuthController to something like localhost/laravel/public/index.php/ to get to the home page, but it doesn't work and still goes to http://localhost/auth/login. I would be very grateful to anyone that could help me out or explain to me how I can make the redirecting work after logging in or failing to log in.
Just fixed my own problem: it turns out that I was posting my login form to /auth/login (I had just copied the example from the laravel docs), so I changed that to /laravel/public/index.php/auth/login and now everything is acting as it should again!
its better to use
php artisan serve
in your project route if you're developing in localhost because you can control your routes more easily and you can get rid of localhost/laravel/public/index.php/ .
I am trying to set up a 301 redirect for the "Default-route" in codeigniter.
I know I can set up a route to another page, but I need it to redirect instead.
Does anyone know how?
Yes you can set a controller function on error page where we will call a view
$route['404_override'] = 'errors/index_404';
errors is controller and index_404 is action(function) where we calling our custom view page
I want to redirect my all old url to new url.
My few old URLs are
domain.com/
domain.com/submit
domain.com/get/soft-name
domain.com/most-downloaded
etc, etc,
Now i want to redirect my all url to
domain.com/en
domain.com/en/submit
domain.com/en/get/soft-name
domain.com/en/most-downloaded
I am using CodeIgniter. Please Suggest me some code for route.php
thanks in advance
If you want to handle this in your routing, you could just do this:
$route['(:any)'] = "en/$1";