简体   繁体   English

Laravel-301永久移动(来自磁盘缓存)

[英]Laravel - 301 Moved Permanently (from disk cache)

When I navigate to the URL localhost/changecontrol , I expect the index.blade.php to be loaded, instead I get an empty 200 OK response after a 301 Moved Permanently (from disk cache) . 当我导航到URL localhost/changecontrol ,我希望将加载index.blade.php ,而不是在301 Moved Permanently (from disk cache)后得到一个空的200 OK响应。 The network tab shows this: 网络标签显示如下:

changecontrol -> Status Code:301 Moved Permanently (from disk cache)
changecontrol/ -> 200 OK

The browser automatically adds the trailing slash to the URL, presumably because of the weird 301 error. 浏览器自动将尾部斜杠添加到URL,大概是由于301错误引起的。 I've tried different browsers and the same thing happens. 我尝试了不同的浏览器,并且发生了相同的事情。

I've also tried all the usual cache clears: route:clear , cache:clear , view:clear . 我还尝试了所有常用的缓存清除: route:clearcache:clearview:clear

Route 路线

Route::namespace('ChangeControl')->group(function() {
    Route::group(['prefix' => 'changecontrol'], function() {
        Route::get('', 'ChangeController@index');
        ...
    });
});

Controller 控制者

public function index()
{
    return view('changecontrol.index');
}

Path to view 查看路径

views
    changecontrol
        index.blade.php

I have an identical set up for another system which uses exactly the same structure, route setup etc. and that one is working fine. 我为另一个系统使用了完全相同的设置,该系统使用完全相同的结构,路由设置等,并且工作正常。

If I amend the route to Route::get('index', 'ChangeController@index'); 如果我将路由修改为Route::get('index', 'ChangeController@index'); and then navigate to changecontrol/index , the view will load as expected. 然后导航到changecontrol/index ,该视图将按预期加载。

So I really don't know what's going wrong? 所以我真的不知道怎么回事? Why does it work for one system and not the other? 为什么它只适用于一个系统而不适用于另一个系统?

Okay - after taking a closer look at the web.config : 好吧-在仔细查看web.config

<match url="^(.*)/$" ignoreCase="false" />
<conditions>
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="/{R:1}" />

This particular rule was causing the issue, because I had a folder where it shouldn't have been: 此特定规则导致了此问题,因为我有一个不应放置的文件夹:

I had a folder public/changecontrol (which was created mistakenly and never removed). 我有一个文件夹public/changecontrol (错误创建,并且从未删除过)。 The above rule was matching with this and that's why it was redirecting. 上面的规则与此匹配,这就是为什么要重定向。

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

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