迁移到Linux服务器后的301重定向循环访问Nova

时间:2019-09-01 21:17:40

标签: laravel-nova

我的Laravel应用程序和Nova在XAMPP下运行的本地Windows 7 PC开发环境中运行良好。在这种环境下不使用SSL。

但是在将应用程序迁移到运行带有SSL的EasyApache WHM / Cpanel的Linux服务器之后。

Nova在登录之前和之后都会引发重定向循环(只能通过直接输入/ nova / login来访问登录页面)。

301重定向在/ nova和/ nova /之间交替出现

https://app.mydomain.com/nova
301 Moved Permanently
https://app.mydomain.com/nova/
301 Moved Permanently
https://app.mydomain.com/nova
301 Moved Permanently
https://app.mydomain.com/nova/
301 Moved Permanently
https://app.mydomain.com/nova
301 Moved Permanently
https://app.mydomain.com/nova/
301 Moved Permanently
https://app.mydomain.com/nova
301 Moved Permanently
https://app.mydomain.com/nova/

etc...

HTTP标头

>>> https://app.mydomain.com/nova

> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------

Status: 301 Moved Permanently
Code:   301
Date:   Sun, 01 Sep 2019 20:31:33 GMT
Server: Apache
Location:   https://app.mydomain.com/nova/
Content-Length: 242
Connection: close
Content-Type:   text/html; charset=iso-8859-1

>>> https://app.mydomain.com/nova/

> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------

Status: 301 Moved Permanently
Code:   301
Date:   Sun, 01 Sep 2019 20:31:33 GMT
Server: Apache
Location:   https://app.mydomain.com/nova
Content-Length: 241
Connection: close
Content-Type:   text/html; charset=iso-8859-1

>>> https://app.mydomain.com/nova

> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------

Status: 301 Moved Permanently
Code:   301
Date:   Sun, 01 Sep 2019 20:31:34 GMT
Server: Apache
Location:   https://app.mydomain.com/nova/
Content-Length: 242
Connection: close
Content-Type:   text/html; charset=iso-8859-1

>>> https://app.mydomain.com/nova/

> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------

Status: 301 Moved Permanently
Code:   301
Date:   Sun, 01 Sep 2019 20:31:35 GMT
Server: Apache
Location:   https://app.mydomain.com/nova
Content-Length: 241
Connection: close
Content-Type:   text/html; charset=iso-8859-1


>>> https://app.mydomain.com/nova

> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------

Status: 301 Moved Permanently
Code:   301
Date:   Sun, 01 Sep 2019 20:31:35 GMT
Server: Apache
Location:   https://app.mydomain.com/nova/
Content-Length: 242
Connection: close
Content-Type:   text/html; charset=iso-8859-1

etc etc

仅使用标准的CPANEL .htaccess文件

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^public
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php7_module>

</IfModule>
<IfModule lsapi_module>

</IfModule>
# END cPanel-generated php ini directives, do not edit

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php72” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php72 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

真的不确定其他地方。我已经运行过:php artisan cache:clear,config:cache,config:clear,view:clear

这是Nova的已知错误吗?任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

问题出在Cpanel在EasyApache 4上创建的默认.htaccess中。请注意,我注释了Rewrite Engine启用后的前两行,并用以下两行替换了它们:

IfModule mod_rewrite.c>
    RewriteEngine on

   # RewriteCond %{REQUEST_URI} !^public
   # RewriteRule ^(.*)$ public/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
     RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php7_module>

</IfModule>
<IfModule lsapi_module>

</IfModule>
# END cPanel-generated php ini directives, do not edit

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php72” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php72 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit