繁体   English   中英

为什么laravel不进入包含index.php的公用文件夹

[英]why laravel is not entering into public folder which contains index.php

我有一个problem我的程序未进入公用文件夹。

我所做的是:

  1. server.php更改为index.php

  2. css,js,images移到root文件夹,但copied .htaccess copiedroot文件夹

现在我的代码以root身份进入index.php

<?php

/**
 * Laravel - A PHP Framework For Web Artisans
 *
 * @package  Laravel
 * @author   Taylor Otwell <taylor@laravel.com>
 */

$uri = urldecode(
    parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);

// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
    return false;
}


echo __DIR__.'/public/index.php'; die;  <-- for debuggig when i remove 500 error

require_once __DIR__.'/public/index.php';

死之前的上述代码给出了 /home/ebsprint/public_html/enigma-crm/public/index.php

现在真正的问题(文件夹公共-文件)

public 
        -  .htaccess
        -  index.php  

文件夹里面的公共 index.php

<?php

      echo 'here'; die;

给出500错误

问题 :在本地环境下工作正常,但是在托管时, index.php调用不会转到public / index.php

只需添加.htaccess代码,您无需更改Laravel目录结构。 在根目录下使用此代码

RewriteEngine on
RewriteCond %{HTTP_HOST} ^yourdomain.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.yourdomain.com$ [NC,OR]
RewriteCond %{REQUEST_URI} !public/
RewriteRule (.*) /public/$1 [L]

暂无
暂无

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

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