简体   繁体   English

Laravel GET在POST表格301上永久移动

[英]Laravel GET moved permanently on POST forms 301

I have this very weird error. 我有这个很奇怪的错误。

Whenever I attempt to use a form on this particular call, it will automatically do a Moved Permanently 301 call to the exact same page as GET. 每当我尝试在此特定调用上使用表单时,它将自动对与GET完全相同的页面进行“永久移动301”调用。 I'm not sure what is causing this but I'm guessing this is something with how Laravel handles URLs. 我不确定是什么原因造成的,但是我猜这与Laravel如何处理URL有关。

For example I have: 例如,我有:

<?php echo Form::open(array('url' =>  'storage/remove/?page=' . $page)) ?>

Where $page is a _GET variable. 其中$ page是_GET变量。

When I run this page in FireBug, I see that it always tries to redirect it to a GET page. 当我在FireBug中运行此页面时,我看到它总是尝试将其重定向到GET页面。

My routes: 我的路线:

Route::any("storage/{id?}", array("uses" => "StorageController@index", "before" => array("auth", "maintenance_check")));
Route::post("storage/remove", array("uses" => "StorageController@remove", "before" => array("auth", "csrf_check", "maintenance_check")));

Can someone let me know what I'm doing wrong for this issue? 有人可以让我知道我在这个问题上做错了什么吗?

Perharps the optional {id} parameter "catches" the /remove segment, therefore the router never triggers Route::post() . Perharps可选的{id}参数“捕获” /remove段,因此路由器从不触发Route::post() Did you try to put Route::post() before Route::any() ? 您是否尝试将Route::post()放在Route::any()

要添加方法post

<?php echo Form::open(array('url' =>  'storage/remove/?page=' . $page, 'method' => 'post')) ?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM