简体   繁体   中英

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

i have a problem my program is not entering into public folder.

what i have done is:

  1. changed server.php to index.php

  2. moved css,js,images to root folder but copied .htaccess to root folder

now my code enters into index.php in root

<?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';

the above code before die gives /home/ebsprint/public_html/enigma-crm/public/index.php

now the real problem (folder public - files)

public 
        -  .htaccess
        -  index.php  

folder public inside index.php

<?php

      echo 'here'; die;

gives 500 error

Question : on local environment it is working fine, but on hosting, root index.php call is not going to public/index.php

Just add .htaccess code and you don't require to change Laravel directory structure. use this code under the root directory

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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