Skip to content

Instantly share code, notes, and snippets.

@shingorow
Created March 2, 2017 09:11
Show Gist options
  • Save shingorow/2a9d18aa3c25d96476d7a7f1e9ad7d88 to your computer and use it in GitHub Desktop.
Save shingorow/2a9d18aa3c25d96476d7a7f1e9ad7d88 to your computer and use it in GitHub Desktop.
PHP の Slim 3 をレンタルサーバーで使うための設定
RewriteEngine On
# Some hosts may require you to use the `RewriteBase` directive.
# If you need to use the `RewriteBase` directive, it should be the
# absolute physical path to the directory that contains this htaccess file.
#
# RewriteBase /
RewriteCond %{REQUEST_URI} !(^/public/)
RewriteRule ^ index.php [QSA,L]
<?php
if (PHP_SAPI == 'cli-server') {
// To help the built-in PHP dev server, check if the request was actually for
// something which should probably be served as a static file
$url = parse_url($_SERVER['REQUEST_URI']);
$file = __DIR__ . $url['path'];
if (is_file($file)) {
return false;
}
}
require __DIR__ . '/vendor/autoload.php';
session_start();
// Instantiate the app
$settings = require __DIR__ . '/src/settings.php';
$app = new \Slim\App($settings);
// Set up dependencies
require __DIR__ . '/src/dependencies.php';
// Register middleware
require __DIR__ . '/src/middleware.php';
// Register routes
require __DIR__ . '/src/routes.php';
// Run app
$app->run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment