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]
としてpublic
へhtaccess
を追加しました、それは動作します。)
<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();
あなたのホストは 'mod_rewrite'が有効になっていることを100%か? – Hackerman
はいhttp://support.hostgator.com/articles/how-to-enable-mod_rewrite-and-mod_speling – jozenbasin
アプリケーションはローカルで動作しましたか?あなたの 'publicに' index.php'ファイルのコードを投稿できますか? 'フォルダ? – Hackerman