Laravel 5.8 public 文件夹重定向到 "Index of /" 页面

Laravel 5.8 public folder redirecting to "Index of /" page

我刚刚将我的 laravel 项目移动到我的子域 http://1hpold.kairedesu.com/

然而,它一直显示 "Index of /" 页面而不是我的 Laravel 视图。

我在 public 文件夹中配置了 .htaccess 文件:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>


    php_value upload_max_filesize 20M
    php_value post_max_size 20M
    php_value max_input_time 600
    php_value max_execution_time 600


    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]


    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ / [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

我坚持了三天。这种重定向问题我做错了什么?

在你的项目根目录中添加这个 .htaccess 保持原样 public/.haccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/ [L]
</IfModule>

# Set the “ea-php71” package as the default “PHP” programming language.
<IfModule mime_module>
  AddType application/x-httpd-ea-php71 .php .php7 .phtml
</IfModule>

根据我的laravel-2019-06-24.log,我检测到这个错误的来源:

[2019-06-24 10:48:54] local.ERROR: Connection refused [tcp://127.0.0.1:6379] (View: /home/cp938874/public_html/1hpold/resources/views/2018template2/cookies_modal.blade.php) (View: /home/cp938874/public_html/1hpold/resources/views/2018template2/cookies_modal.blade.php) 

所以我所做的就是删除 cms_index.blade.php

上的 @include('2018template2.cookies_modal') 视图
<!DOCTYPE html>
<html lang="en">
    <!--more codes...-->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4"
        crossorigin="anonymous">
    <link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN"
        crossorigin="anonymous">
    <script src="https://code.jquery.com/jquery-3.1.0.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.css" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick-theme.css" />
    <link href="{{ asset('/2018template2/css/custom.css') }}" rel="stylesheet">
    <!-- Loader -->
    <script type="text/javascript">
        function makeLoader() {
            var counter = 0;

            var register = function(id) {
                var delay = counter * 6000;
                counter++;

                var url = '/section/' + id;

                var loadHere = document.getElementById('load_' + id);

                var success = function(result) {
                    loadHere.innerHTML = result;
                };

                var delayedAction = function() {
                    var params = {
                        'url' : url,
                        'success' : success
                    };
                    $.ajax(params);
                };

                window.setTimeout(delayedAction, delay);
            };

            return {
                'register' : register
            };
        }

        var loader = makeLoader();
    </script>
    <!-- End Loader -->
    @include('2018template2.scripts.google_analytics')
    @include('2018template2.scripts.zendesk')
    @include('2018template2.scripts.facebook_pixel')
    <!--anchor link animation-->
        <link rel="stylesheet" href="{{ url('/2018template2/css/tomloprodModal-1.0.2.min.css') }}">
        <script type="text/javascript" src="{{ url('/2018template2/js/tomloprodModal.js') }}"></script>
        <!-- Global site tag (gtag.js) - Google Ads: 1054844942 --> <script async src="https://www.googletagmanager.com/gtag/js?id=AW-1054844942"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'AW-1054844942'); </script>

</head>
<body>
    @include('2018template2.layouts.header')
    @include('2018template2.layouts.promo_slider')

    <section class="jumbotron">
        <div class="container">
            <div class="row">
                <div class="col-md-7 col-sm-12 text-white">
                    <div class="jumboheader">Get your manuscripts edited/proofread</div>
                    <div class="jumboheader">before publication</div>
                    <div class="jumboheader">for a low price</div>
                    <p class="jumbocontent">1-Hour Proofreading is committed to helping writers and non-native English speakers send their messages across clearly and accurately. From publishers, self-publishers, businesses, academics, and students, to writers of all genres, we are an awesome proofreading buddy!</p>
                    <p class="jumbobutton">
                            <button class="buttonjumbo1 text-white hrefbutton btn-order toQuote">
                                <b>START NOW</b>
                            </button>
                        <a href="#howItWorksSection">
                            <button class="buttonjumbo text-white hrefbutton btn-order-2">LEARN MORE</button>
                        </a>
                    </p>
                </div>
                <div class="col-md-5 d-none d-md-block">
                    <div class="jumbocont">
                        <div class="dollarjumbo text-white liberationboldita">$</div>
                        <div class="dollarnumber text-white liberationboldita">9</div>
                        <div class="dollarperpage text-white liberationboldita">per page</div>
                        <img src="https://www.inwrite.com/1hp/2018template2/images/hand.png" alt="..." class="dollarimage">
                    </div>
                </div>
            </div>
        </div>
    </section>
    <div>
        <div class="jumbotroninput order-div" id="enterwordcount">
            <div class="container">
                <div class="row">
                    <div class="col-md-6">
                        <div class="text-white textjumboinput">How many words does your document contain?</div>
                        <div class="input-group mb-3">
                            <input type="text"
                                   onkeydown="handleKeyUp(event)" 
                                   class="form-control jumboinput js-word-count-visible hp" 
                                   placeholder="Enter word count" />
                            <div class="input-group-append">
                                <button class="btn btn-outline-secondary jumboinputbot text-white btn-order"
                                        onclick="handleCreateOrder(event)"
                                        type="button">Create Order!</button>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-3 col-sm-6">
                        <div class="">
                            <button class="buttonjumbo1input textinputjumbo hrefbutton jumbobuttoninput btn-order-2"
                                    onclick="showQuoteModal(event)">
                                <b>GET QUOTE!</b>
                            </button>
                        </div>
                    </div>
                    <div class="col-md-3 col-sm-6">
                        <div class="">
                            <a href="{{ url('/contact-us') }}">
                                <button class="buttonjumboinput text-white hrefbutton jumbobuttoninput btn-order-2">
                                    <b>NEED HELP?</b>
                                </button>
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    @include('2018template2.about_new')
    @if(count($sections) > 0)
        @foreach($sections as $i => $section)
            <?php $count = 1; ?>
            @if($count == 1)
                @include('2018template.sections.' . $section->layout->name)
                <?php $count += 1; ?>
            @else
                <div id="load_{{ $section->id }}">
                </div>
                <script type="text/javascript">
                    loader.register({{ $section->id }});
                </script>
            @endif
        @endforeach
    @endif    
    @include('2018template2.layouts.footer')

    <form action="{{ url('/word-count') }}" 
          method="post" 
          class="js-wordcount-form">
        {{ csrf_field() }}
        <input type="hidden" 
               name="word_count" 
               class="js-word-count-hidden" />
    </form>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ"
        crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm"
        crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.js"></script>
    <script type="text/javascript">
        function handleCreateOrder(event) {
            var qs = (cs) => { return document.querySelector(cs) };
            qs('.js-wordcount-form').submit();
        }     
        function handleKeyUp(event) {
            var qs = (cs) => { return document.querySelector(cs) };
            setTimeout(() => {
                console.log(qs('.js-word-count-hidden').value);
                if(event.keyCode != 13) {
                    qs('.js-word-count-hidden').value =
                        qs('.js-word-count-visible').value;
                    return;
                }

                if(isNaN(qs('.js-word-count-hidden').value)) {
                    alert('Please enter a number.');
                    return;
                }

                qs('.js-wordcount-form').submit();
            }, 250);
        }
        $(document).ready(function () {
            $('.testimonialslist').slick({
                slidesToShow: 3,
                slidesToScroll: 1,
                autoplay: true,
                autoplaySpeed: 2000,
                responsive: [{
                        breakpoint: 1200,
                        settings: {
                            slidesToSh: 2,
                            slidesToScroll: 1
                        }
                    }, {
                        breakpoint: 1024,
                        settings: {
                            slidesToShow: 1,
                            slidesToScroll: 1
                        }
                    }, {
                        breakpoint: 600,
                        settings: {
                            slidesToShow: 1,
                            slidesToScroll: 1
                        }
                    },
                    {
                        breakpoint: 480,
                        settings: {
                            slidesToShow: 1,
                            slidesToScroll: 1
                        }
                    }
                ]
            });
        });
    </script>
     <!--iframe chat box styling-->
    <script type="text/javascript">
         setTimeout(function() {
         // get the zopim button from inserted iframe
         var $zopimClass = $(".zopim iframe:first").contents().find(".button_text.jx_ui_Widget");
         // change css ...
         $zopimClass.css("cssText", "background-color: #f7353c !important;");
         var $zopimClass2 = $(".zopim iframe:first").contents().find(".meshim_widget_widgets_Favicon.favicon");
         // change css ...
         $zopimClass2.css("cssText", "background-color: #ed1c24 !important;");
         var $zopimClass3 = $(".zopim iframe:first").contents().find(".meshim_widget_widgets_TitleBar.title_bar.desktop.ltr.br");
         // change css ...
         $zopimClass3.css("cssText", "background-color: #ed1c24 !important;");
         var $zopimClass4 = $(".zopim iframe:first").contents().find(".meshim_widget_widgets_ConnAwareSubmit");
         // change css ...
         $zopimClass4.css("cssText", "background-color: #ed1c24 !important;");
         var $zopimClass5 = $(".zopim iframe:first").contents().find(".meshim_widget_widgets_ConnAwareSubmit:hover");
         // change css ...
         $zopimClass5.css("cssText", "background-color: #f7353c !important; transition:0.3s;");
        }, 5000);
    </script>
    <!--for start now button on the banner-->
    <script type="text/javascript">
        $(document).ready(function () {
          $('.toQuote').click(function (){
            $(".hp").focus();
            $('html, body').animate({
              scrollTop: $(".order-div").offset().top
            }, 1000)   
          })
        });
    </script>
    <!--for start now button on the pricing list boxes-->
    <script type="text/javascript">
        $(document).ready(function () {
          $('.pricinglimargin .buttonjumbo1').click(function (){
            $('html, body').animate({
              scrollTop: $(".order-div").offset().top
            }, 1000)
            $(".hp").focus();
          })
        });
    </script>
    <!--for get started button-->
    <script type="text/javascript">
        $(document).ready(function () {
          $('.aboutUs .buttonabout').click(function (){
            $('html, body').animate({
              scrollTop: $(".order-div").offset().top
            }, 1000)
            $(".hp").focus();
          })
        });
    </script>
    <!--for subscription link-->
    <script type="text/javascript">
        $(document).ready(function () {
          $('#subscribelink').click(function (){
            $('html, body').animate({
              scrollTop: $(".subscribe").offset().top
            }, 1000)
            $(".jumboinput").focus();
          })
        });
    </script>
    <!--learn more link-->
    <script type="text/javascript">
        $(document).ready(function () {
          $('.jumbotron .btn-order-2').click(function (){
            $('html, body').animate({
              scrollTop: $("#howItWorksSection").offset().top
            }, 1000)
          })
        });
    </script>
    <!--how it works section learn more-->
    <script type="text/javascript">
        $(document).ready(function () {
          $('.howitworks > .container > .row:nth-child(3) .buttonabout').click(function (){
            $('html, body').animate({
              scrollTop: $(".howcanwehelpyou").offset().top
            }, 1000)
          })
        });
    </script>
    <!--lets get started link-->
    <script type="text/javascript">
        $(document).ready(function () {
          $('.howitworks > .container > .row:nth-child(8) a > button').click(function (){
            $('html, body').animate({
              scrollTop: $(".order-div").offset().top
            }, 1000);
            $(".hp").focus();
          })
        });
    </script>
    <!--top menu animation-->
    <script type="text/javascript">
        $(document).ready(function () {
          //about us links
          $('#aboutUs').click(function (e){
            e.preventDefault();
            $('html, body').animate({
              scrollTop: $(".aboutUs").offset().top
            }, 1000)
          })
          //how it works links
          $('#howItWorks').click(function (e){
            e.preventDefault();
            $('html, body').animate({
              scrollTop: $(".howitworks").offset().top
            }, 2000)
          })
          //pricing links
          $('#pricing').click(function (e){
            e.preventDefault();
            $('html, body').animate({
              scrollTop: $(".pricing").offset().top
            }, 3000)
          })
          //faq links
          $('#faq').click(function (e){
            e.preventDefault();
            $('html, body').animate({
              scrollTop: $("#faqSection").offset().top
            }, 3000)
          })
        });
    </script>
    <!--footer menu animation-->
    <script type="text/javascript">
        $(document).ready(function () {
          //about us links
          $('#aboutlink').click(function (e){
            e.preventDefault();
            $('html, body').animate({
              scrollTop: $(".aboutUs").offset().top
            }, 3000)
          })
          //how it works links
          $('#howitworkslink').click(function (e){
            e.preventDefault();
            $('html, body').animate({
              scrollTop: $(".howitworks").offset().top
            }, 2000)
          })
          //pricing links
          $('#pricinglink').click(function (e){
            e.preventDefault();
            $('html, body').animate({
              scrollTop: $(".pricing").offset().top
            }, 1000)
          })
          //testimonials links
          $('#testimonialslink').click(function (e){
            e.preventDefault();
            $('html, body').animate({
              scrollTop: $(".testimonials").offset().top
            }, 1000)
          })
          //subscribe links
          $('#subscribelink').click(function (e){
             e.preventDefault();
            $('html, body').animate({
              scrollTop: $(".subscribe").offset().top
            }, 1000)
            $(".subscribe .jumboinput").focus();
          })
          //faq links
          $('#faqlink').click(function (e){
            $('html, body').animate({
              scrollTop: $("#faqSection").offset().top
            }, 1000)
          })
        });
    </script>
    <!--change span text to link-->
    <script type="text/javascript">
        $(document).ready(function () {
        $(".threecolshowitworks > .col-md-4:first-child > .howitworkscontent > b > span").replaceWith('<a class="goto" href="page/ordering-process">here</a>');
        $(".threecolshowitworks > .col-md-4:nth-child(2) > .howitworkscontent > b > span").replaceWith('<a class="goto" href="page/about-your-order">here</a>');
        $(".threecolshowitworks > .col-md-4:last-child > .howitworkscontent > b > span").replaceWith('<a class="goto" href="page/ordering-process">here</a>');
        /*$(".howitworks > .container > .row:nth-child(8) a").attr('href','#enterwordcount');*/
        $("div:nth-child(13)").attr('id','faqSection');
        $( ".about4col > .col-md-3.col-sm-6.text-center" ).hover(function() {
          $( this ).toggleClass('hoverIt');
          $( ".aboutcontentcol" ).toggleClass('hoverIt');
        });
        });
    </script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('.about4col > .col-md-3.col-sm-6.text-center:first-child').click(function(){
                $(this).addClass('clickIt');
                $('.aboutcontentcol').addClass('clickIt');
                $('.about4col > .col-md-3.col-sm-6.text-center:nth-child(2)').removeClass('clickIt');
                $('.about4col > .col-md-3.col-sm-6.text-center:nth-child(3)').removeClass('clickIt');
                $('.about4col > .col-md-3.col-sm-6.text-center:last-child').removeClass('clickIt');
                $('.about4col > .col-md-3.col-sm-6.text-center:nth-child(2) .aboutcontentcol').removeClass('clickIt');
                $('.about4col > .col-md-3.col-sm-6.text-center:nth-child(3) .aboutcontentcol').removeClass('clickIt');
                $('.about4col > .col-md-3.col-sm-6.text-center:last-child .aboutcontentcol').removeClass('clickIt');
                $('#about-sub-1').css("cssText","display:block;");
                $('#about-sub-2').css("cssText","display:none;");
                $('#about-sub-3').css("cssText","display:none;");
                $('#about-sub-4').css("cssText","display:none;");
                $('.aboutcontent').css("cssText","transition:0.3s; animation: fadein 1.5s;");
            });/*click first picture*/
            $('.about4col > .col-md-3.col-sm-6.text-center:nth-child(2)').click(function(){
                $(this).addClass('clickIt');
                $('.aboutcontentcol').addClass('clickIt');
                $('.about4col > .col-md-3.col-sm-6.text-center:first-child').removeClass('clickIt');
                $('.about4col > .col-md-3.col-sm-6.text-center:nth-child(3)').removeClass('clickIt');
                $('.about4col > .col-md-3.col-sm-6.text-center:last-child').removeClass('clickIt');
                $('.about4col > .col-md-3.col-sm-6.text-center:first-child .aboutcontentcol').removeClass('clickIt');
                $('.about4col > .col-md-3.col-sm-6.text-center:nth-child(3) .aboutcontentcol').removeClass('clickIt');
                $('.about4col > .col-md-3.col-sm-6.text-center:last-child .aboutcontentcol').removeClass('clickIt');
                $('#about-sub-1').css("cssText","display:none;");
                $('#about-sub-2').css("cssText","display:block;");
                $('#about-sub-3').css("cssText","display:none;");
                $('#about-sub-4').css("cssText","display:none;");
                $('.aboutcontent').css("cssText","transition:0.3s; animation: fadein 1.5s;");
            });/*click second picture*/
            $('.about4col > .col-md-3.col-sm-6.text-center:nth-child(3)').click(function(){
                $(this).addClass('clickIt');
                $('.aboutcontentcol').addClass('clickIt');
                $('.about4col > .col-md-3.col-sm-6.text-center:first-child').removeClass('clickIt');
                $('.about4col > .col-md-3.col-sm-6.text-center:nth-child(2)').removeClass('clickIt');
                $('.about4col > .col-md-3.col-sm-6.text-center:last-child').removeClass('clickIt');
                $('.about4col > .col-md-3.col-sm-6.text-center:first-child .aboutcontentcol').removeClass('clickIt');
                $('.about4col > .col-md-3.col-sm-6.text-center:nth-child(2) .aboutcontentcol').removeClass('clickIt');
                $('.about4col > .col-md-3.col-sm-6.text-center:last-child .aboutcontentcol').removeClass('clickIt');
                $('#about-sub-1').css("cssText","display:none;");
                $('#about-sub-2').css("cssText","display:none;");
                $('#about-sub-3').css("cssText","display:block;");
                $('#about-sub-4').css("cssText","display:none;");
                $('.aboutcontent').css("cssText","transition:0.3s; animation: fadein 1.5s;");
            });/*click third picture*/
            $('.about4col > .col-md-3.col-sm-6.text-center:last-child').click(function(){
                $(this).addClass('clickIt');
                $('.aboutcontentcol').addClass('clickIt');
                $('.about4col > .col-md-3.col-sm-6.text-center:first-child').removeClass('clickIt');
                $('.about4col > .col-md-3.col-sm-6.text-center:nth-child(2)').removeClass('clickIt');
                $('.about4col > .col-md-3.col-sm-6.text-center:nth-child(3)').removeClass('clickIt');
                $('.about4col > .col-md-3.col-sm-6.text-center:first-child .aboutcontentcol').removeClass('clickIt');
                $('.about4col > .col-md-3.col-sm-6.text-center:nth-child(2) .aboutcontentcol').removeClass('clickIt');
                $('.about4col > .col-md-3.col-sm-6.text-center:nth-child(3) .aboutcontentcol').removeClass('clickIt');
                $('#about-sub-1').css("cssText","display:none;");
                $('#about-sub-2').css("cssText","display:none;");
                $('#about-sub-3').css("cssText","display:none;");
                $('#about-sub-4').css("cssText","display:block;");
                $('.aboutcontent').css("cssText","transition:0.3s; animation: fadein 1.5s;");
            });/*click last picture*/
        });
    </script>
@include('2018template2.quote_modal')

    <img src="{{ url('/2018template2/images/spin.gif') }}" 
         class="js-wait-gif animate-load"/>
</body>
</html>

cookies_modal.blade.php

<!-- cookies modal -->
<div style="display:none">aaaaa {{ \Request::ip() }} </div>
<?php

    $ip = \Request::ip();
    $key = "1hp.cookie.popup.$ip";
    $check = \Redis::get($key); //this causes an error, redis is somewhat outdated, so i removed that view extension


?>
@if($check == null)
<div class="tm-modal tm-effect js-cookies-modal" id="cookiesModal">
    <div class="tm-wrapper bg-cookie">
        <div class="tm-title">
            <span class="tm-XButton tm-closeButton"></span>  
            <hr class="linehere">
            <h3 class="tm-title-text cookie-heading">Welcome to 1-Hour Proofreading!</h3> 
            <hr class="linehere">
        </div>
        <div class="tm-content div-contents">
            <p class="cookie-content">We use cookies to improve your experience on this website.</p>
            <input type="button" class="btn btn-secondary btn-accept-cookie" value="Accept" onclick="acceptCookies()" />
        </div>
    </div>
</div>

<script type="text/javascript">
document.addEventListener("DOMContentLoaded", () => {
    var cs1 = '.js-cookies-modal';
    var qs = (cs) => { return document.querySelector(cs1).querySelector(cs) };

    TomloprodModal.start({
        closeOut: true,
        showMessages: true,
        bgColor: "#FFFFFF",
        textColor: "#333333"
    });

    TomloprodModal.openModal("cookiesModal");
});

function acceptCookies() {
    var cs1 = '.js-cookies-modal';
    var qs = (cs) => { return document.querySelector(cs1).querySelector(cs) };
    qs('.tm-closeButton').click();
}
</script>
    <?php 
    $ip = \Request::ip();
    $key = "1hp.cookie.popup.$ip";
    \Redis::set($key, time());
    \Redis::expire($key, 60 * 60 * 24);

    ?>
@endif

而且,我再次检查了link,不再重定向回"Index of /"页面!我明天将其标记为已检查。