本文最后更新于 2024年5月16日。
I have the Rewrite commands in the .htaccess file like so:
RewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^ index.php [QSA,L]
I have the Slim hello code in the index.php file:
<?php require __DIR__ . '/vendor/autoload.php';date_default_timezone_set ( "America/New_York" ); // $log = new Monolog\Logger('name'); // $log->pushHandler(new Monolog\Handler\StreamHandler('app.log', Monolog\Logger::WARNING)); // $log->addWarning('Foo');$app = new \Slim\Slim();$app->get('/hello/:name', function ($name) { echo "Hello, $name";});$app->run();?>
Yes, the monolog is working as is the datetime function.
I have tried to modify the base as instructed also, though I realize that really isn't the error I'm getting. Also, just for my FYI, does this look like the way to make the absolute path to my .htaccess file?
RewriteBase /Applications/MAMP/htdocs/SimplePHPWebsite/
Update: I've added code from the next video which is partially working, Snippet:
$app->get('/', function() { echo 'Hello, this is the homepage.';});$app->get('/contact', function() { echo 'contact us.';});
This works for the homepage, but not for the contact page.
I'm using localhost:8888 with MAMP
From:https://teamtreehouse.com/community/how-to-fix-the-requested-url-was-not-found-on-this-server-error-for-the-helloname-url