簡體   English   中英

可在本地開發機上精簡工作,但不能在遠程服務器上

[英]Slim working on local dev machine but not remote server

我正在玩Slim,它在運行MAMP的本地計算機上運行良好。 根URL顯示“ home”,/ features顯示“ features”。 但是,在我的Linode計算機上,只有根目錄有效(“ home”)。 當我進入/ features時,我得到了404。

<?php

//Slim Framework
require 'Slim/Slim.php';

\Slim\Slim::registerAutoloader();

//Instantiate, register URIs
$app = new \Slim\Slim(array(
    'debug' => true
));

$app->get('/', 'getHome');
$app->get('/features', 'getFeatures');

$app->run();

function getHome() {
    echo "home";
};


function getFeatures() {
    echo "features";
};

?>

原來,我的.htaccess文件中沒有打開mod重寫功能。 上傳以下.htaccess解決了我的問題:

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_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

暫無
暫無

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

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