[英]Laravel forces redirect to public folder when user is not logged in
I added this rule into the .htaccess
to redirect all the requests to the public folder: 我将此规则添加到.htaccess
以将所有请求重定向到公用文件夹:
RewriteRule ^(.*)$ /public/$1 [L,NC]
This way I can strip the public
word from the URI, although both mydomain.com/home
and mydomain.com/public/home
would work. 这样,尽管mydomain.com/home
和mydomain.com/public/home
都可以工作,但我可以从URI中剥离public
单词。
I now implemented the basic user authentication but what happens is that: 我现在实现了基本的用户身份验证,但是发生的是:
mydomain.com/admin
and is not logged in, Laravel redirects him or her to mydomain.com/public/login
instead of mydomain.com/login
如果用户请求mydomain.com/admin
并没有登录,Laravel重定向他或她mydomain.com/public/login
代替mydomain.com/login
mydomain.com/public/admin
instead of mydomain.com/admin
当用户对自己进行身份验证时,Laravel会将其重定向到mydomain.com/public/admin
而不是mydomain.com/admin
Based on this, I guess that Laravel, somewhere, explicitates that redirects must be made at /public/whatever
. 基于此,我猜想Laravel在某处明确指出必须在/public/whatever
进行重定向。 I tried to figure out where redirect()
helper is explicitated but I couldn't find it. 我试图找出在哪里redirect()
helper被显式了,但是我找不到它。 My questions are: 我的问题是:
/public/whatever
? 如果是 ,Laravel在哪里定义必须在/public/whatever
处进行重定向? Where I can find redirect()
helper? 在哪里可以找到redirect()
助手? Apache 阿帕奇
The framework ships with a public/.htaccess file that is used to allow URLs without index.php. 该框架附带一个public / .htaccess文件,该文件用于允许没有index.php的URL。 If you use Apache to serve your Laravel application, be sure to enable the mod_rewrite module. 如果使用Apache服务Laravel应用程序,请确保启用mod_rewrite模块。
If the .htaccess file that ships with Laravel does not work with your Apache installation, try this one: 如果Laravel随附的.htaccess文件不适用于您的Apache安装,请尝试以下操作:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
If your web host doesn't allow the FollowSymlinks option, try replacing it with Options +SymLinksIfOwnerMatch. 如果您的虚拟主机不允许使用FollowSymlinks选项,请尝试将其替换为Option + SymLinksIfOwnerMatch。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.