簡體   English   中英

FuelPHP從網址中刪除公共

[英]FuelPHP remove public from url

首先,對不起,但是我是個非常大的初學者,因此,如果您願意,可以否決這個問題。

因此,我遍歷了很多教程,對我而言唯一可行的是拉出公用文件夾內容。

問題是我遇到了很多錯誤。

錯誤:

Warning: require(\bootstrap.php) [function.require]: failed to open stream: No such file or directory in C:\EasyPHP\www\fuelphp\index.php on line 33

Fatal error: require() [function.require]: Failed opening required '\bootstrap.php' (include_path='.;C:\php\pear') in C:\EasyPHP\www\fuelphp\index.php on line 33

所以我發現DOCROOT是C:\\EasyPHP\\www\\fuelphp\\ ,所以我將需要以這種方式拉東西localhost / fuelphp / fuel / core

原始索引看起來像這樣

<?php
/**
 * Set error reporting and display errors settings.  You will want to change these when in production.
 */
error_reporting(-1);
ini_set('display_errors', 1);

/**
 * Website document root
 */
define('DOCROOT', __DIR__.DIRECTORY_SEPARATOR);

/**
 * Path to the application directory.
 */
define('APPPATH', realpath(__DIR__.'/../fuel/app/').DIRECTORY_SEPARATOR);

/**
 * Path to the default packages directory.
 */
define('PKGPATH', realpath(__DIR__.'/../fuel/packages/').DIRECTORY_SEPARATOR);

/**
 * The path to the framework core.
 */
define('COREPATH', realpath(__DIR__.'/../fuel/core/').DIRECTORY_SEPARATOR);

// Get the start time and memory for use later
defined('FUEL_START_TIME') or define('FUEL_START_TIME', microtime(true));
defined('FUEL_START_MEM') or define('FUEL_START_MEM', memory_get_usage());

// Boot the app
require APPPATH.'bootstrap.php';

// Generate the request, execute it and send the output.
try
{
    $response = Request::forge()->execute()->response();
}
catch (HttpNotFoundException $e)
{
    $route = array_key_exists('_404_', Router::$routes) ? Router::$routes['_404_']->translation : Config::get('routes._404_');
    if ($route)
    {
        $response = Request::forge($route)->execute()->response();
    }
    else
    {
        throw $e;
    }
}

// This will add the execution time and memory usage to the output.
// Comment this out if you don't use it.
$bm = Profiler::app_total();
$response->body(
    str_replace(
        array('{exec_time}', '{mem_usage}'),
        array(round($bm[0], 4), round($bm[1] / pow(1024, 2), 3)),
        $response->body()
    )
);

$response->send(true);

比修改這個

<?php
/**
 * Set error reporting and display errors settings.  You will want to change these when in production.
 */
error_reporting(-1);
ini_set('display_errors', 1);

/**
 * Website document root
 */
define('DOCROOT', '/');

/**
 * Path to the application directory.
 */
define('APPPATH', 'fuel/app/').DIRECTORY_SEPARATOR;

/**
 * Path to the default packages directory.
 */
define('PKGPATH', 'fuel/packages/').DIRECTORY_SEPARATOR;

/**
 * The path to the framework core.
 */
define('COREPATH', 'fuel/core/').DIRECTORY_SEPARATOR;

// Get the start time and memory for use later
defined('FUEL_START_TIME') or define('FUEL_START_TIME', microtime(true));
defined('FUEL_START_MEM') or define('FUEL_START_MEM', memory_get_usage());

// Boot the app
require APPPATH.'bootstrap.php';

// Generate the request, execute it and send the output.
try
{
    $response = Request::forge()->execute()->response();
}
catch (HttpNotFoundException $e)
{
    $route = array_key_exists('_404_', Router::$routes) ? Router::$routes['_404_']->translation : Config::get('routes._404_');
    if ($route)
    {
        $response = Request::forge($route)->execute()->response();
    }
    else
    {
        throw $e;
    }
}

// This will add the execution time and memory usage to the output.
// Comment this out if you don't use it.
$bm = Profiler::app_total();
$response->body(
    str_replace(
        array('{exec_time}', '{mem_usage}'),
        array(round($bm[0], 4), round($bm[1] / pow(1024, 2), 3)),
        $response->body()
    )
);

$response->send(true);

現在公眾不在URL中,但是當我打開網站時我遇到了很多錯誤,我看到安裝了正斜杠卻使用了反斜杠,但無法真正發現問題

Warning: require_once(fuel/core/classes\error.php) [function.require-once]: failed to open stream: No such file or directory in C:\EasyPHP\www\fuelphp\fuel\core\base.php on line 25

Fatal error: require_once() [function.require]: Failed opening required 'fuel/core/classes\error.php' (include_path='.;C:\php\pear') in C:\EasyPHP\www\fuelphp\fuel\core\base.php on line 25

能否請別人給我一個提示,如何修改索引就可以了?

謝謝

您無需修改​​索引文件即可實現所要嘗試的功能。

Fuel設計為駐留在文檔根目錄(docroot)之上。 您的docroot似乎是www /。

這意味着您的目錄結構實際上應如下所示:

C:\EasyPHP\fuelphp\
C:\EasyPHP\www\

FuelPHP zip文件或git克隆(或者您可以獲取它)包含一個名為public的文件夾。 此文件夾是您的docroot的假定名稱,因此,在您遇到的情況下,應將public/的內容復制到www/

但是,您可以在嘗試時將其全部設置在docroot內,該過程記錄在此處的FuelPHP網站上。

如第3點所述,出於安全原因,強烈建議不要在Web服務器的文檔根目錄內安裝Fuel。

但是,在某些情況下,您想這樣做,[...]

在這種情況下,您需要在文檔根目錄中放置一個附加的.htaccess文件,該文件將把對站點根目錄的請求重定向到您的公用文件夾,並修改重寫以包括公用文件夾:

<IfModule mod_rewrite.c>
    RewriteEngine on

    RewriteBase /public

    RewriteRule ^(/)?$ index.php/$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

默認情況下,index.php的默認配置考慮/ fuel /文件夾的位置。 以下面的路徑定義為例

define('COREPATH', realpath(__DIR__.'/../fuel/core/').DIRECTORY_SEPARATOR);

__DIR__    - Path of current working directory, i.e. wherever index.php is
..         - go up a directory, i.e. directory above wherever index.php is
fuel/      - Fuel folder
core/      - Core folder within fuel/

realpath() - Resolves the .. to it's real location and makes sure / is correct or changes to \ depending on the OS

之所以會出現斜線,是因為您已經在不使用realpath()情況下將代碼硬編碼/

您還可以使用VirtualHost將http://project.dev/定向到項目的公共路徑。

在您的文件中:

C:\\ EasyPHP \\ www \\ fuelphp \\ public \\ .htaccess

設置RewriteBase此值: /easyphp/www/fuelphp/public

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM