2012-08-02 3 views
0

Сначала извините, но я действительно большой новичок, поэтому вы можете проголосовать за этот вопрос, если хотите.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\, так что мне нужно будет тянуть материал таким образом, локальный/fuelphp/топливо/ядро ​​

оригинальный индекс выглядит следующим образом

<?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, но им получает кучу ошибок, когда я открываю сайт, я вижу Insted переднего слэша UTS задних косых черт, но не может реально найти проблему

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 

может понравиться кому-нибудь, дайте мне подсказку, как изменить индекс, чтобы все было в порядке?

спасибо

ответ

3

Вам не нужно изменять индексный файл для того, чтобы достичь того, чего вы пытаетесь.

Топливо предназначено для размещения над корнем документа (docroot). Ваш docroot, похоже, www /.

Это означает, что ваша структура каталогов должна фактически быть следующим:

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

FuelPHP почтовый файл или мерзавец клон (или же вы можете получить его) содержит папку под названием public. Эта папка является вымышленным именем вашего DOCROOT, и, следовательно, в вашей ситуации содержание public/ должны быть скопированы в www/

Однако вы можете установить его все внутри DOCROOT, как вы пытаетесь и процесс документируется на Сайт FuelPHP here.

As explained in point 3, for security reasons it is strongly advised NOT to install Fuel inside your webserver's document root.

However, there are cases where you would like to do that, [...]

In that case, you need an additional .htaccess file that you need to place in your document root, which will redirect requests to the site root to your public folder, and also modifies the rewrites to include the public folder:

<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 учитывает положение/топлива/папки по умолчанию. Возьму, к примеру, следующему определению пути

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()

+0

добавил HTAccess к корню, и теперь работает отлично, один последний вопрос, безопасно ли использовать эту Htaccess? потому что теперь я могу получить к нему доступ таким образом http: // localhost/fueljob/и таким образом http: // localhost/fueljob/public, разве это не проблема? – Side

+0

Это не проблема, нет. Вы можете запретить доступ при доступе к нему через последний URL-адрес, используя .htaccess, если вы действительно этого хотели, но это не проблема, и да, я бы сказал, что это безопасно использовать. –

+0

Большое вам спасибо за помощь – Side

0

Вы также можете использовать VirtualHost направить http://project.dev/ к общественному пути вашего проекта.

0

В файле:

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

Установите RewriteBase это значение: /easyphp/www/fuelphp/public