2017-05-22 3 views
0

Slim PHPフレームワークをHostGatorアカウントにデプロイしようとしています。HostGatorのPHP Slim3でカスタムhtaccessファイルを使用

マイプロジェクトのソースは、次のようになります。

project/ 
├── .htaccess 
├── src/ 
│ ├── classes/ 
│ ├── vendor/ 
│ ├── composer.json 
│ ├── routes.php 
│ ├── settings.php 
│ └── index.php 
└── public/ 
    ├── index.php 
    └── .htaccess 

と同じように展開され、projectフォルダがpublic_htmlのようなものと他のものがあり、私のHostgatorのアカウントの最高レベルのフォルダ、です。 tutorial

は、私はそのような(単語のための単語)どこかにもPHP7を使用する設定が含まれて私は(ルートhtaccessファイルにこれを追加した道に沿っても

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule . index.php [L] 

としてpublichtaccessを追加しました、それは動作します。)

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

私は500 Internal Server Errorを取得し、これらの新しいhtaccessファイルをサイトにアクセスしようとします。

明らかに私のhtaccess(s)が間違っています、私はちょうど何が間違っているのか分かりません。私は何が起こると思われるかは、最初にpublic/index.phpに送信し、Slimに送信する必要があり、自分自身がルーティングを処理するはずです。


公共/ index.phpを

publicを移動
require __DIR__ . '/../src/vendor/autoload.php'; 
require __DIR__ . '/../src/dependencies.php'; 
require __DIR__ . '/../src/middleware.php'; 
require __DIR__ . '/../src/routes.php'; 
$settings = require __DIR__ . '/../src/settings.php'; 

use \Psr\Http\Message\ServerRequestInterface as Request; 
use \Psr\Http\Message\ResponseInterface as Response; 

// require custom classesw 
spl_autoload_register(function ($classname) { 
    require ("../src/classes/" . $classname . ".php"); 
}); 

session_start(); 

$app = new \Slim\App($settings); 

$container = $app->getContainer(); 
$container['logger'] = function($c) { 
    $logger = new \Monolog\Logger('my_logger'); 
    $file_handler = new \Monolog\Handler\StreamHandler("../src/logs/app.log"); 
    $logger->pushHandler($file_handler); 
    return $logger; 
}; 



$app->get('/', function (Request $request, Response $response) { 
    $response->getBody()->write("Hello"); 
    return $response; 
}); 
$app->run(); 
+0

あなたのホストは 'mod_rewrite'が有効になっていることを100%か? – Hackerman

+0

はいhttp://support.hostgator.com/articles/how-to-enable-mod_rewrite-and-mod_speling – jozenbasin

+0

アプリケーションはローカルで動作しましたか?あなたの 'publicに' index.php'ファイルのコードを投稿できますか? 'フォルダ? – Hackerman

答えて

0

メインhtaccesspublic_htmlにファイルが(別名何も)通常ではありません何に戻りました。

公共htaccessファイル

<IfModule mod_rewrite.c> RewriteEngine on #RewriteBase/ RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . index.php [QSA,L] </IfModule>

関連する問題