Wamp,SlimPHP和Htaccess [英] Wamp, SlimPHP and Htaccess

查看:56
本文介绍了Wamp,SlimPHP和Htaccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在让Slim识别以下内容时遇到问题:

I am having issues with getting Slim to recognize the following:

$app = new \Slim\Slim();

$app->get('/', function () {
    echo "Hello";
});

$app->get('/:name', function () {
    echo "Hello";
});

$app->run();

它将看到第一条路线很好,第二条路线如何返回

It will see the first route just fine, how ever the second one returns a

Not Found

The requested URL /image-uploader/gg was not found on this server.

这使我相信我没有在wamp中启用重写写模块.所以我启用了它并将AllowOverride设置为All

Which lead me to believe I didnt have the re-write mod enabled in wamp. So I enabled it and set AllowOverride to All

然后我重新启动wamp并访问了localhost/image-uploader/,我得到了Hello,无论如何访问第二条路线都会出现上述错误.

I then restarted wamp and visited localhost/image-uploader/ and I get Hello, how ever visiting the second route gives the error above.

为什么?我的htaccess就是这样:

Why? My htaccess is as such:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule index.php [L]
</IfModule>

推荐答案

由于您的项目不在根文件夹中,而在image-uploader文件夹中,因此您的路径不正确.

Since your project is not in root folder but in image-uploader folder, your path is not correct.

您可以按以下方式更改RewriteBase(假设htaccess位于image-uploader文件夹中)

You can change RewriteBase as follow (assuming your htaccess is in image-uploader folder)

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /image-uploader/

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
</IfModule>

现在,它应该可以正常工作了.其实,我对SlimPHP的了解不多,但看起来还不错

Now, it should be working as expected. Actually, i don't know much more about SlimPHP but it looks like it's fine

这篇关于Wamp,SlimPHP和Htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆