WAMP,SlimPHP和Htacess [英] Wamp, SlimPHP and Htacess

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

问题描述

我有让斯利姆认识到以下几个问题:

  $应用=新\修身\斯利姆();

$ APP->获得('/',函数(){
    回声你好;
});

$ APP->获得(/:名称',函数(){
    回声你好;
});

$ APP->运行();
 

这首先看到的路线就好了,怎么过第二个返回

 未找到

所请求的URL /图像上传/ GG在此服务器上找到。
 

这使我相信我没有在瓦帕启用重写mod。所以我启用了它,并设置的AllowOverride 所有

我再重新启动WAMP,并参观了本地主机/图像上传/ ,我得到您好,逛怎么过的第二条路线提供了上述错误。

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

 < IfModule mod_rewrite.c>
RewriteEngine叙述上
的RewriteBase /
重写规则^指数\ .PHP $  -  [L]
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则的index.php [L]
< / IfModule>
 

解决方案

由于您的项目是不是在根文件夹中,但在图像上传文件夹,你的路径不正确。

您可以修改的RewriteBase 如下(假设你的htaccess是在图像上传文件夹)

 < IfModule mod_rewrite.c>
RewriteEngine叙述上
的RewriteBase /图像上传/

重写规则^指数\ .PHP $  -  [L]
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^的index.php [L]
< / IfModule>
 

现在,就应该按预期方式工作。其实,我不知道更多关于SlimPHP但它看起来像它的优良

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.

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

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

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>

解决方案

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

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>

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和Htacess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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