简体   繁体   English

在使用苗条的PHP中,我无法路由到URL / loveshared

[英]In PHP using slim I can not route to URL /loveshared

A very weird question. 一个非常奇怪的问题。

I can not setup a route in slim to use the URL /loveshared 我无法在苗条中设置路线以使用URL / loveshared

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

If I navigate in my browser to localhost/loveshared, I get a 404. I also get this 404 message when I push to my server. 如果在浏览器中导航到localhost / loveshared,则会收到404。当我推送到服务器时,也会收到此404消息。

I did a Find in Files... in the top direction of my project for the string loveshared. 我在项目的顶部执行了“在文件中查找...”操作,以获取字符串loveshared。 The only place it found the string was in my router file. 它找到字符串的唯一位置是我的路由器文件中。

I also went through and did: /l, /lo, /lov, /love, /loves.../loveshared All the routes work, up until loveshared. 我还经历了以下操作:/l、/lo、/lov、/love、/loves.../loveshared所有路线都有效,直到loveshare。 I also did /sharedlove and /stuffshared and they both worked. 我也做了/ sharedlove和/ stuffshared,它们都起作用。

Can anyone else confirm that /loveshared does not work with slim as a route? 其他人可以确认/ loveshared不适用于slim吗?

Ok, I downloaded a fresh copy of Slim 2.2.0 , placed it as-is on my personal site ( PHP 5.3.13 ) running on Linux duhr 2.6.32.8 in shared host environment (Dreamhost). 好的,我下载了Slim 2.2.0的新副本,将它原样放置在我的个人站点( PHP 5.3.13 )上, Linux duhr 2.6.32.8在共享主机环境(Dreamhost)中的Linux duhr 2.6.32.8上运行。 Then I created a file, t.php , and pasted the following into it: 然后,我创建了一个文件t.php ,并将以下内容粘贴到其中:

<?php

require 'Slim/Slim.php';

\Slim\Slim::registerAutoloader();

$app = new \Slim\Slim();

$app->get('/loveshared', function () use ($app) {
    echo "<p>This is a test of the loveshared controller label in the URL of a Slim project.</p>";
});

$app->run();

http://jfcoder.com/slim/t.php/loveshared http://jfcoder.com/slim/t.php/loveshared

And it runs as expected. 并且它按预期运行。 There's either some kind of environment cause (rogue or misconfigured .htaccess file?), or something. 可能是某种环境原因(流氓或配置错误的.htaccess文件?)引起的。 You would need to recreate it in some way to be able to triangulate and find the problem. 您将需要以某种方式重新创建它,以便能够进行三角测量并找到问题。

Have you tried what I have done and see if it still causes the problem you're describing? 您是否尝试过我所做的事情,看看它是否仍然导致您描述的问题?

Works fine for me 对我来说很好

<?php
require 'Slim/Slim.php';

\Slim\Slim::registerAutoloader();

$app = new \Slim\Slim();

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

$app->run();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM